Find Right Interval LeetCode solution in C++

1
class Solution {
2
public:
3
vector<int> findRightInterval(vector<vector<int>> &intervals) {
4
map<int, int> mp;
5
int n = intervals.size();
6

7
for (int i = 0; i < n; i++) mp[intervals[i][0]] = i;
8

9
vector<int> ans;
10
for (auto &i : intervals) {
11
auto it = mp.lower_bound(i[1]);
12
ans.push_back(it == mp.end() ? -1 : it->second);
13
}
14

15
return ans;
16
}
17
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0