On this page
LIS
Solving LIS using DP/Binary search.
Problem
Longest increasing subsequence.
Pattern
This problem demonstrates the DP/Binary search pattern.
Approach
Patience sorting with binary search.
Solution
// Solution for LIS
// Pattern: DP/Binary search
// O(n log n) time
Complexity
O(n log n) time
Best Practices
- Identify the pattern before coding — pattern recognition saves time
- Handle edge cases: empty input, single element, duplicates
- Use descriptive variable names even in timed interviews
- Test with the provided examples plus one custom case