Advertisement
momo2345

find the frequency

Aug 30th, 2020
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.30 KB | None | 0 0
  1. class Solution {
  2. public:
  3.     vector<int> searchRange(vector<int>& nums, int target) {
  4.         int l=lower_bound(nums.begin(),nums.end(),target)-nums.begin();
  5.         int u=upper_bound(nums.begin(),nums.end(),target)-nums.begin();
  6.         if(l==u) return {-1,-1};
  7.         else return{l,u-1};
  8.     }
  9. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement