Longest String
Reported by candidates from Zolando's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Zalando's Longest String question hit the assessment circuit in August 2024, and it's a dynamic-programming pattern wrapped in a deceptively simple name. You're probably looking at a string problem where the naive greedy approach fails and you need to build up a table of optimal substructure. The trick is recognizing that the "longest" thing you're hunting for isn't just character count. StealthCoder will catch you if you blank on the recurrence relation the night of.
Pattern and pitfall
This is a DP string problem, likely involving either longest common subsequence, longest increasing subsequence applied to strings, or longest substring with some constraint. The pattern screams: break the string into overlapping subproblems, memoize or tabulate results, and avoid recomputing. Common pitfall: candidates try to solve it greedily (pick the longest chunk at each step) and get stuck on overlapping constraints. The recurrence relation will be something like dp[i] depends on dp[j] for all j less than i, filtered by some validity check. Build a 1D or 2D table, fill it bottom-up, and return the max. If you hit a wall during the OA, StealthCoder reads the exact problem statement and gives you the recurrence structure in real time.
If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.
You can drill Longest String cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.
Get StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as longest common subsequence. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Zolando's OA.
Zolando reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Longest String FAQ
Is this actually hard or just pattern-matching?+
It's pattern-matching if you've seen LCS or longest-increasing-subsequence before. If not, the recurrence relation will stump you. The implementation is straightforward once you have the DP structure right. Most failures are conceptual, not coding.
How much time should I spend on this problem in the OA?+
If you recognize the DP pattern in the first 2-3 minutes, you're on track. If you're still thinking it's greedy after 5 minutes, stop, pivot to DP, and build the table. Don't waste 15 minutes on a dead-end approach.
What's the space-time trade-off I need to know?+
Most candidates use O(n^2) time and O(n) or O(n^2) space. You can often optimize space by only keeping the previous row or column, but don't sacrifice correctness for micro-optimization. Get the right answer first.
Will Zalando accept a brute-force solution?+
Unlikely. If n is small (under 20), maybe. But assess problems are usually designed to fail brute-force on hidden test cases. DP is the intended approach. Write it cleanly and it will pass.
What if I blank on the recurrence during the OA?+
Write out a few small examples by hand and look for the pattern. If that doesn't work in 3 minutes, you have a safety net. That's what StealthCoder is for on the day.