SHARE
TWEET

Untitled

a guest Aug 14th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public int search(int[] nums, int target) {
  2.     int low = 0;
  3.     int high = nums.length - 1;
  4.  
  5.     while (low <= high) {
  6.         int mid = (low + high) >>> 1;
  7.  
  8.         if (nums[mid] < target) {
  9.             low = mid + 1;
  10.         } else if (nums[mid] > target) {
  11.             high = mid - 1;
  12.         } else {
  13.             return mid;
  14.         }
  15.     }
  16.  
  17.     return -1;
  18. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top