Find Right Interval LeetCode solution in C++
1class Solution {2public:3vector<int> findRightInterval(vector<vector<int>> &intervals) {4map<int, int> mp;5int n = intervals.size();67for (int i = 0; i < n; i++) mp[intervals[i][0]] = i;89vector<int> ans;10for (auto &i : intervals) {11auto it = mp.lower_bound(i[1]);12ans.push_back(it == mp.end() ? -1 : it->second);13}1415return ans;16}17};