
Problem
Solution
Submissions
Longest Increasing Subsequence
Certification: Advanced Level
Accuracy: 0%
Submissions: 0
Points: 10
Write a C# program to find the length of the longest strictly increasing subsequence in an array of integers. 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.
Example 1
- Input: nums = [10,9,2,5,3,7,101,18]
- Output: 4
- Explanation: The longest increasing subsequence is [2,3,7,101], therefore the length is 4.
Example 2
- Input: nums = [0,1,0,3,2,3]
- Output: 4
- Explanation: The longest increasing subsequence is [0,1,2,3], therefore the length is 4.
Constraints
- 1 ≤ nums.length ≤ 2500
- -10^4 ≤ nums[i] ≤ 10^4
- Time Complexity: O(n²)
- Space Complexity: O(n)
Editorial
My Submissions
All Solutions
Lang | Status | Date | Code |
---|---|---|---|
You do not have any submissions for this problem. |
User | Lang | Status | Date | Code |
---|---|---|---|---|
No submissions found. |
- Consider using dynamic programming to solve this problem
- Create a DP array where dp[i] represents the length of the LIS ending at index i
- For each element, compare with all previous elements to find the longest chain
- The maximum value in the DP array will be your answer
- For better time complexity, consider using binary search