Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public int search(int[] nums, int target) {
- int low = 0;
- int high = nums.length - 1;
- while (low <= high) {
- int mid = (low + high) >>> 1;
- if (nums[mid] < target) {
- low = mid + 1;
- } else if (nums[mid] > target) {
- high = mid - 1;
- } else {
- return mid;
- }
- }
- return -1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement