Longest Increasing Subsequence
Last updated: June 17, 2026
Quick Overview
Find the length of the longest strictly increasing subsequence. Explore O(n^2) DP and O(n log n) binary search approaches. A common Google DP question.
Google
Coding & Algorithms
Software Engineer
Software Engineer
Onsite
Coding & Algorithms
Medium
197
0
397 solved
Find the length of the longest strictly increasing subsequence. Explore O(n^2) DP and O(n log n) binary search approaches. A common Google DP question.
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Problem Analysis
The Longest Increasing Subsequence (LIS) problem can be approached using the dynamic programming (DP) technique due to its optimal substructure property. The key observation is that for any element in...
Approach
We will implement two solutions:
- O(n^2) DP Approach:
- Create a DP array where
dp[i]represents the length of the longest increasing subsequence that ends with the element at indexi. ...
- Create a DP array where
Submit Your Answer
Markdown supported