Q Link : https://leetcode.com/problems/maximum-population-year/
My Code:
class Solution {
public int maximumPopulation(int[][] logs) {
int max = 0, year = logs[0][0],i,j,c = 0;
for(i = 0; i < logs.length - 1; i++)
{
c = 0;
for(j = 0; j < logs.length; j++)
{
if(i != j)
{
if(logs[i][1] - 1 >= logs[j][0])
c++;
}
}
if(c > max)
{
max = c;
year = logs[i][0];
}
}
return year;
}
}```
am quite sure that the issue with my code is something related to lifespan of ith person but not able to rectify the issue.
