Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing

Longest increasing subsequence

Python data engineering interview problem. Difficulty: advanced. Pattern: Dynamic Programming. About 20 minutes. Part of the Pro drill bank.

Length of the longest strictly increasing subsequence of a list. Treat this as a production helper: match the contracted return shape, including empty and duplicate inputs.

Implement lis_length(nums: list[int]) -> int. A subsequence keeps the original order but may skip elements. Return the length of the longest strictly increasing subsequence of nums. Equal values do not extend a subsequence. An empty list gives 0.

Requirements

  • Strictly increasing; equal values do not count.

Constraints

  • Up to 100,000 values.
  • Values can be negative or repeat.

Examples

Input: lis_length([2, 2, 3, 3]) Output: 2 The repeated values do not extend a strictly increasing subsequence: 2, 3 is the longest, so the length is 2.

Topics: lakebench, python, subsequence, patience sorting.

More Python interview questions · All interview problems · Learn data engineering

advanced

Longest increasing subsequence

Interview-style drill: Length of the longest strictly increasing subsequence of a list.

Implement `lis_length(nums: list[int]) -> int`. A subsequence keeps the original order but may skip elements. Return the length of the longest **strictly** increasing subsequence of `nums`. Equal values do not extend a subsequence. An empty list gives `0`.