1854. Maximum Population Year Easy
1/**
2 * [1854] Maximum Population Year
3 *
4 * You are given a 2D integer array logs where each logs[i] = [birthi, deathi] indicates the birth and death years of the i^th person.
5 * The population of some year x is the number of people alive during that year. The i^th person is counted in year x's population if x is in the inclusive range [birthi, deathi - 1]. Note that the person is not counted in the year that they die.
6 * Return the earliest year with the maximum population.
7 *
8 * Example 1:
9 *
10 * Input: logs = [[1993,1999],[2000,2010]]
11 * Output: 1993
12 * Explanation: The maximum population is 1, and 1993 is the earliest year with this population.
13 *
14 * Example 2:
15 *
16 * Input: logs = [[1950,1961],[1960,1971],[1970,1981]]
17 * Output: 1960
18 * Explanation:
19 * The maximum population is 2, and it had happened in years 1960 and 1970.
20 * The earlier year between them is 1960.
21 *
22 * Constraints:
23 *
24 * 1 <= logs.length <= 100
25 * 1950 <= birthi < deathi <= 2050
26 *
27 */
28pub struct Solution {}
29
30// problem: https://leetcode.com/problems/maximum-population-year/
31// discuss: https://leetcode.com/problems/maximum-population-year/discuss/?currentPage=1&orderBy=most_votes&query=
32
33// submission codes start here
34
35impl Solution {
36 pub fn maximum_population(logs: Vec<Vec<i32>>) -> i32 {
37 0
38 }
39}
40
41// submission codes end
42
43#[cfg(test)]
44mod tests {
45 use super::*;
46
47 #[test]
48 fn test_1854() {
49 }
50}
51
Back
© 2025 bowen.ge All Rights Reserved.