On this page
Longest increasing subsequence
Interview Question 30: Longest increasing subsequence
Question
Explain and implement Longest increasing subsequence. Discuss time/space complexity and trade-offs.
What Interviewers Look For
- Clear communication of approach before coding
- Correct handling of edge cases
- Clean, readable implementation
- Awareness of alternatives
Approach
- Clarify inputs, outputs, and constraints
- Start with a brute-force solution if needed
- Optimize and discuss complexity
- Test with examples including edge cases
// Skeleton — fill in during practice
function solution(input) {
// O(n) typical for linear scans
return input;
}
Follow-up Questions
- How would this change at scale?
- What breaks with concurrent access?
- How would you test this thoroughly?