5 views
# LIS Patience (Practice 4070): Drill Interviewers love lis patience because it checks whether you can state the invariant before coding. Here is a compact rehearsal note. ## Approach Maintain tails of increasing subsequences; binary search replace. ```python import bisect def length_of_lis(nums): tails = [] for x in nums: i = bisect.bisect_left(tails, x) if i == len(tails): tails.append(x) else: tails[i] = x return len(tails) ``` ## Complexity Linear in the dominant input size for the scan; heap/tree variants add a log factor. ## Interview pitfalls State the invariant out loud, name the complexity, then code. Skipping the invariant is the usual fail mode. ## Practicing out loud Narrate the approach, complexity and one edge case in under a minute. Disclosure: I work on Linkjob AI, a real-time interview assistant. If you want live practice help, see [this tool](https://www.linkjob.ai/).