Here is the code:
public int Search(int[] nums, int target) {
return search(nums,target,0,nums.Length-1);
}
public int search(int[] n,int t,int s,int e)
{
if(s>e)
{
return -1;
}
int mid = (s+e)/2;
if(n[mid]==t)
{
return mid;
}
else if(t<n[mid])
{
return search(n,t,s,mid-1);
}
else
{
return search(n,t,mid+1,e);
}
}
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