Back to the 100
Course Practice
Hard

Longest Increasing Subsequence II

LAB

Return the longest strictly increasing subsequence length where adjacent chosen values differ by at most k.

EXAMPLES

Example 1
Input
{
  "nums": [
    4,
    2,
    1,
    4,
    3,
    4,
    5,
    8,
    15
  ],
  "k": 3
}

Output
5

FUNCTION SHAPE

nums: intArrayk: intint
00:00
2 local tests readyRun with ⌘/Ctrl + Enter. Your code stays in this browser.

Runs solve(...) locally in a browser worker. SWE Playbook does not submit your code. Only run code you trust; Python code may access the network.