C++ Hashmap Solution
Approach :- Iterate over the array and store the frequencies of the years in range [birth,year). Iterate over the hashmap to find the year with maximum count (A
Approach :- Iterate over the array and store the frequencies of the years in range [birth,year). Iterate over the hashmap to find the year with maximum count (Also store the last saved count value along with the year for comparison).\n```\nclass Solution {\npublic:\n    int maximumPopulation(vector<vector<int>>& logs) {\n   \n        int n = logs.size();\n        \n        unordered_map<int,int> s;\n        for(int i=0;i<n;++i){\n            for(int k = logs[i][0]; k != logs[i][1];++k){\n                s[k]++ ;\n            }\n        }\n        \n        int year = 0; //Stores the last year with maximum count\n        int count = 0; //Stores count of last encountered max value\n        \n        for(auto it:s){\n            if(it.second > count){\n                count = it.second;\n                year = it.first;\n            }\n            if(it.second == count){\n                year = min(year,it.first);\n            }\n        }    \n        return year;  \n    }\n     \n};\n```\n\nHope this helps!\nStay safe.
['C']