Longest Unequal Adjacent Groups Subsequence I
A easy-tier problem at 68% community acceptance, tagged with Array, String, Dynamic Programming. Reported in interviews at fourkites and 1 others.
Longest Unequal Adjacent Groups Subsequence I is one of those problems that looks deceptively simple but trips up candidates who skip the setup. You see it at FourKites and ZS Associates, and the 67% acceptance rate reflects a real split between people who spot the pattern immediately and those who don't. The twist isn't complex, but it's easy to miss: you're not looking for the longest subsequence of distinct elements. You're looking for the longest subsequence where no two adjacent elements come from the same group. Read the problem statement carefully the first time, because rushing the constraint is where most candidates lose ground.
Companies that ask "Longest Unequal Adjacent Groups Subsequence I"
Longest Unequal Adjacent Groups 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 because the OA filter rejects engineers who'd pass the on-site. That's a broken filter. This is the workaround.
Get StealthCoderThe trick here is recognizing that this is a filtered dynamic programming problem, not a standard longest-subsequence hunt. You need to track the last group you picked from, not just the last value, and only extend your current sequence if the next element belongs to a different group. Greedy can work once you realize the optimal strategy is to always take an element from a new group if one is available in the remaining window. The pitfall is treating it like longest increasing subsequence or assuming you want maximum diversity of values instead of groups. On the live assessment, if the constraint on group switching isn't clicking, StealthCoder surfaces the working logic instantly, invisible to the proctor, so you don't waste 20 minutes on a wrong model.
Pattern tags
You know the problem.
Make sure you actually pass it.
Longest Unequal Adjacent Groups Subsequence I recycles across companies for a reason. It's easy-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.
Longest Unequal Adjacent Groups Subsequence I interview FAQ
Is this really an easy problem or is the acceptance rate misleading?+
The 67% rate is honest. It's easy once you parse what 'unequal adjacent groups' means. If you misread it as longest distinct values or skip constraint analysis, you'll hit a wall. Most failures aren't algorithmic complexity, they're setup confusion.
Can I solve this with just greedy, or do I need DP?+
Greedy works if you think clearly about the decision at each step: always take the next available element from a different group. DP is safer if you want to be bulletproof about optimality. Either approach is O(n), so pick the one that feels more natural to you.
How does this relate to the DP and Greedy topics listed?+
Both are viable here. DP lets you track state explicitly (last group picked). Greedy works because choosing from a new group whenever possible is always optimal. Understanding when to apply each is more valuable than memorizing one solution.
Will I see this at other companies or is it niche to FourKites and ZS Associates?+
It's reported at two companies so far, so lower frequency than median easy problems. But the pattern of 'adjacent constraint on grouped data' is common in real systems like logistics and analytics, so variants pop up.
What's the most common mistake on this problem?+
Misunderstanding that the constraint is on groups, not values. Candidates often code up longest increasing subsequence or longest distinct elements, then get runtime errors or wrong answer. Verify your constraint understanding before coding.
Want the actual problem statement? View "Longest Unequal Adjacent Groups Subsequence I" on LeetCode →