Originally posted by Deepak Jain:
and for an an array with 5 elements the possible insertion points it can return are -1,-2,-3,-4,-5 and hence the method can return 0,1,2,3,4, -1,-2,-3,-4,-5 and hence the answer should be from -5 to 4.
You have forgotten that one possible insertion point is
after the last element. So the possible insertion points are 0, 1 ,2 ,3 ,4 and 5, which are translated to -1, -2, -3, -4, -5 and -6. Conclusion, the answer in the book is correct.