Longest Increasing Subsequence with Reconstruction
Given an array of $n$ integers, find and return one **strictly** longest increasing subsequence (LIS).
Your solution must run in $O(n \log n)$ time and $O(n)$ space.
**Constraints:**
- $0 \le n \le 10^5$
- Array elements can be any 32-bit integer (including negatives and duplicates)
- "Strictly increasing" means no two equal elements are allowed in the subsequence
- If multiple LIS exist with the same length, return any one of them
**Example 1:**
- Input: `[10, 9, 2, 5, 3, 7, 101, 18]`
- Output: `[2, 3, 7, 18]` (length 4)
- Explanation: `[2, 3, 7, 101]` is also valid.
**Example 2:**
- Input: `[0, 1, 0, 3, 2, 3]`
- Output: `[0, 1, 2, 3]` (length 4)
**Example 3:**
- Input: `[7, 7, 7, 7]`
- Output: `[7]` (length 1)
- Explanation: Strictly increasing means equal elements cannot appear together.
Open the full interactive solver, hints, and worked solution →