Here is the Code:
public int Search(int[] nums, int target) {
int s=0;
int e=nums.Length-1;
while(s<=e)
{
int mid = (s+e)/2;
if(nums[mid]==target)
{
return mid;
}
else if(target<nums[mid])
{
e=mid-1;
}
else
{
s=mid+1;
}
}
return -1;
}
Popular Posts
-
Here is the code: // => Brute Force Solution: O(m* n) static long arrayManipulation(int n, int[][] queries) { ...
-
Whatever it is one fine day everyone on this planet who are born have to die for sure. When you are close ones are with you, you wont know ...
-
HTML: <div class="outer-container"> <div class="inner-container"> <div class="t...
No comments:
Post a Comment