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;
}
Your go-to destination for mastering software development technologies, data structures, and algorithms in an easy-to-understand way!
Popular Posts
-
Here is the Code: class Program { static void Main(string[] args) { Quene q = new Quene(); // This...
-
Here is the code: class Program { static List<int> li = new List<int>(); static void Main(string[] args...
-
Here is the code: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; ...