354. Russian Doll Envelopes Hard
1/**
2 * [354] Russian Doll Envelopes
3 *
4 * You are given a 2D array of integers envelopes where envelopes[i] = [wi, hi] represents the width and the height of an envelope.
5 * One envelope can fit into another if and only if both the width and height of one envelope are greater than the other envelope's width and height.
6 * Return the maximum number of envelopes you can Russian doll (i.e., put one inside the other).
7 * Note: You cannot rotate an envelope.
8 *
9 * Example 1:
10 *
11 * Input: envelopes = [[5,4],[6,4],[6,7],[2,3]]
12 * Output: 3
13 * Explanation: The maximum number of envelopes you can Russian doll is 3 ([2,3] => [5,4] => [6,7]).
14 *
15 * Example 2:
16 *
17 * Input: envelopes = [[1,1],[1,1],[1,1]]
18 * Output: 1
19 *
20 *
21 * Constraints:
22 *
23 * 1 <= envelopes.length <= 10^5
24 * envelopes[i].length == 2
25 * 1 <= wi, hi <= 10^5
26 *
27 */
28pub struct Solution {}
29
30// problem: https://leetcode.com/problems/russian-doll-envelopes/
31// discuss: https://leetcode.com/problems/russian-doll-envelopes/discuss/?currentPage=1&orderBy=most_votes&query=
32
33// submission codes start here
34
35impl Solution {
36 pub fn max_envelopes(envelopes: 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_354() {
49 }
50}
51
Back
© 2025 bowen.ge All Rights Reserved.