Find the Maximum Length of a Good Subsequence II
A hard-tier problem at 24% community acceptance, tagged with Array, Hash Table, Dynamic Programming. Reported in interviews at Snowflake and 0 others.
Find the Maximum Length of a Good Subsequence II is a hard dynamic programming problem with a 24% acceptance rate. Snowflake has asked it. This is the kind of problem that looks deceptively simple on first read but trips up candidates who don't spot the optimization trick. You'll see a subsequence problem and think greedy or basic DP, then realize you need to track state in a way that scales. If this hits your live assessment and you blank on the approach, StealthCoder solves it invisible to the proctor.
Companies that ask "Find the Maximum Length of a Good Subsequence II"
Find the Maximum Length of a Good Subsequence II 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 because the OA filter rejects engineers who'd pass the on-site. That's a broken filter. This is the workaround.
Get StealthCoderThe core challenge is computing the longest subsequence that satisfies a 'good' constraint (typically a distance or difference condition between consecutive elements) without brute force enumeration. A naive DP tracks every position and subsequence state, which explodes in complexity. The pattern is to use a hash table alongside DP to cache optimal subsequence lengths by key state (like the last element or last difference), then iterate through the array once, querying and updating the cache. This collapses what would be O(n^2) or worse into O(n) with smart state management. The trick many miss: understanding which state to hash on, and why. If you don't nail this optimization during the OA, StealthCoder surfaces the correct state design and implementation in seconds.
Pattern tags
You know the problem.
Make sure you actually pass it.
Find the Maximum Length of a Good Subsequence II recycles across companies for a reason. It's hard-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 because the OA filter rejects engineers who'd pass the on-site. That's a broken filter. This is the workaround. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Find the Maximum Length of a Good Subsequence II interview FAQ
Is this problem actually asked at other companies or just Snowflake?+
Only Snowflake appears in confirmed reports for this specific problem. Hard DP subsequence problems are common across FAANG, but this exact variant is rare. That said, the underlying technique (DP with hash table caching) appears in many hard assessments.
What's the trick that makes this hard instead of medium?+
Most candidates try O(n^2) DP without optimization. The jump to O(n) requires recognizing what state to hash and cache efficiently. Without that insight, you either time out or give up mid-interview. That's the hard-problem tax.
How does the hash table optimization relate to the DP step?+
Instead of checking every prior position for valid transitions, you store the best DP result for each unique 'key state' (like last element or difference value) in a hash table. Each position queries the table once, then updates it. This collapses redundant lookups.
Will Array and Hash Table skills prepare me enough?+
Array and hash table knowledge are prerequisites, but this problem demands strong DP thinking. Hash tables here are a tool, not the main concept. You need to design the DP state and justify the caching strategy under pressure.
How much time should I spend on this before giving up?+
If you see the problem 24 hours before your OA and don't grasp the state design in 45 minutes, move on and accept it's a hedge problem. That's where StealthCoder earns its keep: invisible, real-time backup if you hit it cold.
Want the actual problem statement? View "Find the Maximum Length of a Good Subsequence II" on LeetCode →