classSolution { public int searchInsert(int[] nums, int target) { int left=0; int right=nums.length; int mid=0; while(left<right){ mid=left+((right-left)>>1); if(nums[mid]==target){ return mid; }elseif(nums[mid]<target){ left=mid+1; }else{ right=mid; } } return right; } }