Round-Robin WDL Order
Reported by candidates from Capital One's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Capital One reported this one in September 2026, and it looks scarier than it is. Strip the story and it's a counting problem: tally W, D and L, then deal them out in rounds like cards. If you've got an OA coming, this is the kind of question where the setup wastes your time and the real work is ten lines. No sorting of the input needed, whatever the hint says. StealthCoder sits invisibly on your screen as a safety net if you blank mid-assessment, but you probably won't need it for this.
The problem
Given a string sequence containing only W, D, and L, build a reordered string by consuming the available characters cyclically in this order: Append W if any W characters remain. Append D if any D characters remain. Append L if any L characters remain. Repeat this cycle until every input character has been consumed. When a character is exhausted, skip it in later cycles while continuing to consume the other characters in the same cyclic order. Return the reordered string. Function reorderWdl(sequence: String) → String Examples Example 1 sequence = "WWWLLDDLD" return = "WDLWDLWDL" The input has three copies of each character. Each complete W, D, L cycle consumes one of each, producing WDLWDLWDL. Example 2 sequence = "WLDDL" return = "WDLDL" The first cycle produces WDL. No W remains, so the next cycle skips W and appends D followed by L, producing WDLDL. Example 3 sequence = "WWWWLDDL" return = "WDLWDLWW" Two complete cycles consume two copies of each character and produce WDLWDL. Only two W characters remain, so they are appended in the next two cycles, producing WDLWDLWW. Constraints Every character in sequence is W, D, or L.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is that order in the input never matters. Only the counts do. Count each of W, D, L in one pass. Then loop while any count is above zero. Inside the loop, check W, then D, then L in that fixed order, and if a count is positive, append the character and decrement it. Exhausted letters skip themselves automatically, which handles Example 2 and Example 3 with no special casing. The common pitfall is overthinking it with sorting or queues, or building the result with repeated string concatenation. Use a list or StringBuilder and join at the end. Another slip is looping a fixed number of cycles instead of until all counts hit zero. Time is O(n) and extra space is O(n) for the output. If your mind goes blank on the day, StealthCoder is the hedge that reads the prompt and hands you this loop in real time.
The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.
You can drill Round-Robin WDL Order 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 for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Capital One's OA.
Capital One reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Round-Robin WDL Order FAQ
How hard is the Round-Robin WDL Order problem really?+
Easy. It's a counting problem dressed up as a reordering puzzle. Count the three letters, then repeat a fixed W, D, L cycle while any count remains. If you can write a while loop and three if statements, you can solve it in a few minutes.
What's the trick to this Capital One OA question?+
Ignore the input order completely. Only the counts of W, D and L matter. Each cycle appends one of each letter that still has a positive count, in W, D, L order. Skipping exhausted letters falls out of the positive-count check naturally.
Do I need to sort the string?+
No. Even though sorting is hinted, the output isn't sorted, it's interleaved. A frequency count is cleaner and runs in O(n). Sorting would add O(n log n) work and doesn't help you build the cyclic output any faster.
What edge cases should I test?+
Test a string with only one letter type, like all W, which should return the same string. Test an empty string if allowed, and uneven counts like Example 3 where W outlasts the others. Also check that your loop ends only when all three counts are zero.
How do I prepare for this in 48 hours?+
Write this solution once from scratch using a count array and a while loop. Then do two or three other counting or frequency problems so the pattern feels automatic. Keep the output in a list or builder, not repeated string concatenation, and you're set.