diff --git a/Day-26/q3: Find first and last position of element in sorted array/kalpana--cpp.md b/Day-26/q3: Find first and last position of element in sorted array/kalpana--cpp.md new file mode 100644 index 00000000..b1a8f1aa --- /dev/null +++ b/Day-26/q3: Find first and last position of element in sorted array/kalpana--cpp.md @@ -0,0 +1,16 @@ +class Solution { +public: + vector searchRange(vector& nums, int target) { + vector ans(2,-1); + if(nums.size()==0)return ans; + int t1=lower_bound(nums.begin(),nums.end(),target)-nums.begin(); + int t2=upper_bound(nums.begin(),nums.end(),target)-nums.begin(); + if(t1==t2)return ans; + cout<