Longest Subsequence With Limited Value Changes

Asked at Snowflake · Coding Questions · Difficulty: Medium

Pick some elements of an integer array, keeping them in their original order, so that the picked sequence changes value only a few times. A change is a position where an element of the picked sequence differs from the element right after it. Given the array `nums` and a budget `k`, find how many elements you can pick at most while making at most `k` changes.

Loading the problem…