Advertisement
nikunjsoni

1854

May 9th, 2021
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. class Solution {
  2. public:
  3.     int maximumPopulation(vector<vector<int>>& logs) {
  4.         map<int, int>  m;
  5.         for(auto v: logs){
  6.             m[v[0]] += 1;
  7.             m[v[1]] -= 1;
  8.         }
  9.        
  10.         int maxx = -1, count = 0, ans;
  11.         for(auto p: m){
  12.             count += p.second;
  13.             if(count > maxx){
  14.                 maxx = count;
  15.                 ans = p.first;
  16.             }
  17.         }
  18.         return ans;
  19.     }
  20. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement