300. Longest Increasing Subsequence Medium

@problem@discussion
#Array#Binary Search#Dynamic Programming



1/**
2 * [300] Longest Increasing Subsequence
3 *
4 * Given an integer array nums, return the length of the longest strictly increasing subsequence.
5 * A subsequence is a sequence that can be derived from an array by deleting some or no elements without changing the order of the remaining elements. For example, [3,6,2,7] is a subsequence of the array [0,3,1,6,2,2,7].
6 *  
7 * Example 1:
8 * 
9 * Input: nums = [10,9,2,5,3,7,101,18]
10 * Output: 4
11 * Explanation: The longest increasing subsequence is [2,3,7,101], therefore the length is 4.
12 * 
13 * Example 2:
14 * 
15 * Input: nums = [0,1,0,3,2,3]
16 * Output: 4
17 * 
18 * Example 3:
19 * 
20 * Input: nums = [7,7,7,7,7,7,7]
21 * Output: 1
22 * 
23 *  
24 * Constraints:
25 * 
26 * 	1 <= nums.length <= 2500
27 * 	-10^4 <= nums[i] <= 10^4
28 * 
29 *  
30 * Follow up: Can you come up with an algorithm that runs in O(n log(n)) time complexity?
31 * 
32 */
33pub struct Solution {}
34
35// problem: https://leetcode.com/problems/longest-increasing-subsequence/
36// discuss: https://leetcode.com/problems/longest-increasing-subsequence/discuss/?currentPage=1&orderBy=most_votes&query=
37
38// submission codes start here
39
40impl Solution {
41    pub fn length_of_lis(nums: Vec<i32>) -> i32 {
42        0
43    }
44}
45
46// submission codes end
47
48#[cfg(test)]
49mod tests {
50    use super::*;
51
52    #[test]
53    fn test_300() {
54    }
55}
56


Back
© 2025 bowen.ge All Rights Reserved.