MEDIUMasked at 1 company

Find the Maximum Length of a Good Subsequence I

A medium-tier problem at 32% community acceptance, tagged with Array, Hash Table, Dynamic Programming. Reported in interviews at Snowflake and 0 others.

Founder's read

You need to find the maximum length of a "good" subsequence from an array, which means hitting a specific constraint pattern. This is a DP problem with a relatively low acceptance rate of 31.5%, so the trick isn't obvious on first read. Snowflake has asked it. If you're prepping for assessments at companies that drill DP hard, this one sneaks into rotation because the constraint can be misread as purely greedy when it's actually state-dependent. If this problem hits your live assessment and you blank on which DP state to track, StealthCoder solves it invisibly during the screen share.

Companies asking
1
Difficulty
MEDIUM
Acceptance
32%

Companies that ask "Find the Maximum Length of a Good Subsequence I"

If this hits your live OA

Find the Maximum Length of a Good Subsequence I is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an engineer at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share.

Get StealthCoder
What this means

The trap is thinking you can greedily pick elements. You can't. You need dynamic programming with a hash table to track what states (like the last picked element or previous value) are reachable at each length. The key insight is that "good" is context-dependent: the constraint ties together elements in the subsequence, not just the subsequence's structure. Most candidates start by iterating and picking, then realize their greedy pick blocks a better future state. The DP state usually involves the index or value of the last picked element, and you iterate through, deciding whether to include or skip. A hash table lets you avoid O(n^2) collision checks by storing which states exist at each DP level. This requires both pattern recognition and clean state management. If you haven't seen the exact constraint format before and hit this live, StealthCoder reads the problem and surfaces the state transition in seconds.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Find the Maximum Length of a Good Subsequence I recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an engineer at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Find the Maximum Length of a Good Subsequence I interview FAQ

How hard is this compared to standard DP problems?+

The 31.5% acceptance rate signals it's harder than classic DP. The difficulty isn't the DP structure itself, it's correctly identifying which values or positions to track as state. Most candidates either build the wrong state or miss that the constraint links picked elements non-locally.

Do I really need a hash table?+

Yes, unless your constraint is purely linear. The hash table avoids iterating all possible previous states at each step. Without it you'll TLE on larger inputs. It maps the last picked value (or similar) to the max length reachable with that state.

Is this still asked at tech companies?+

Snowflake has asked it. It's less common than two-pointer or basic DP, but it shows up when companies want to test whether you can design a DP state under pressure, not just recognize a known pattern.

What's the difference between this and a standard longest subsequence problem?+

Standard longest-increasing-subsequence is greedy-adjacent. This problem's constraint is not monotonic or self-evident. You must track which previous elements actually unlock future valid picks. The constraint couples non-adjacent elements.

If I see this in an OA, how do I know which state to track?+

Read the constraint carefully. Ask: does picking element X at position i restrict what I can pick at position j > i. If yes, track X (or its value) in DP state. If the constraint also involves the distance between picks (like indices), track that too. Build incrementally and test on examples.

Want the actual problem statement? View "Find the Maximum Length of a Good Subsequence I" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.