Using priority queue
\npublic int maximumPopulation(int[][] logs) {\n        int len=logs.length;\n        PriorityQueue<int[]> pq = new PriorityQueue<>(len,(n1,n2)->n1[1]-n2[1]);\n
```\npublic int maximumPopulation(int[][] logs) {\n        int len=logs.length;\n        PriorityQueue<int[]> pq = new PriorityQueue<>(len,(n1,n2)->n1[1]-n2[1]);\n        int max_count=0,ans=0;\n        Arrays.sort(logs,(n1,n2)->n1[0]-n2[0]);\n        for(int i=0;i<len;i++){\n           \n            while(!pq.isEmpty() && pq.peek()[1]-1<logs[i][0]){\n                \n                pq.poll();\n            }\n            pq.add(logs[i]);\n            if(pq.size()>max_count){\n                max_count=pq.size();\n                ans=logs[i][0];\n            }\n        }\n        return ans;\n}\n```
[]