Hiring process8 levels
  1. 1 IQ Test
  2. 2 Additional Online Test (If Required)
  3. 3 Office Interview with Hiring Manager
  4. 4 Unpaid Test Task (Motivation Check)
  5. 5 Paid Test Task and Follow-Up Interview
  6. 6 Iterative Paid Test Tasks
  7. 7 Office Verification
  8. 8 Final Interview with the Founder

Problems > Longest Increasing Subsequence > Editorial

Longest Increasing Subsequence — Solution & Editorial

Back to the Problem

Patience sorting: keep tails[k] = smallest possible tail of an increasing subsequence of length k+1; each element replaces its lower_bound. The array length is the answer. O(N²) DP times out at 105.

Complexity: O(N log N)

Watch out: Strictly increasing: use lower_bound, not upper_bound (that would allow equal elements).