leetcode-34-Find First and Last Position of Element in Sorted Array

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zem_nezer/article/details/85062851

The problem is not too difficult than previous one, for the leftmost index, assign right = mid - 1 when target == nums[mid] in order to let the pointer try to move left as it can; for the rightmost use the similar one, left = mid + 1 when target == nums[mid] and let the range as right as we can.

猜你喜欢

转载自blog.csdn.net/zem_nezer/article/details/85062851