PracHub
QuestionsCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Capital One

Arrange Match Results in Repeating Win-Draw-Loss Order

Last updated: Jul 22, 2026

Quick Overview

Rearrange a multiset of win, draw, and loss markers into repeated W-D-L rounds, skipping any marker once its supply is exhausted. The problem tests exact multiset preservation, deterministic round order, imbalanced supplies, empty input, and efficient construction for strings up to one million characters.

  • medium
  • Capital One
  • Coding & Algorithms
  • Software Engineer

Arrange Match Results in Repeating Win-Draw-Loss Order

Company: Capital One

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Take-home Project

# Arrange Match Results in Repeating Win-Draw-Loss Order You are given a string containing only `W`, `D`, and `L`. Rearrange all characters into rounds. In each round, append at most one remaining `W`, then one remaining `D`, then one remaining `L`, skipping any character whose supply is exhausted. Continue until no characters remain. Return the resulting string. ## Function Signature ```python def arrange_results(results: str) -> str: ... ``` ## Constraints - `0 <= len(results) <= 1_000_000` - Every character in `results` is one of `W`, `D`, or `L`. - The output must contain exactly the same multiset of characters as the input. ## Examples ```text Input: results = "WWWLLDDLD" Output: "WDLWDLWDL" ``` ```text Input: results = "WLDDL" Output: "WDLDL" ``` ```text Input: results = "WWWWLDDL" Output: "WDLWDLWW" ```

Quick Answer: Rearrange a multiset of win, draw, and loss markers into repeated W-D-L rounds, skipping any marker once its supply is exhausted. The problem tests exact multiset preservation, deterministic round order, imbalanced supplies, empty input, and efficient construction for strings up to one million characters.

Related Interview Questions

  • Reorder a String by Alternating Its Left and Right Ends - Capital One (medium)
  • Sort Every Concentric Matrix Border Clockwise - Capital One (medium)
  • Count Pairs of Cyclically Equivalent Integers - Capital One (medium)
  • Sort Matrix Diagonals By Their Values - Capital One (medium)
|Home/Coding & Algorithms/Capital One

Arrange Match Results in Repeating Win-Draw-Loss Order

Capital One logo
Capital One
Jul 21, 2026, 12:00 AM
mediumSoftware EngineerTake-home ProjectCoding & Algorithms
0
0

Arrange Match Results in Repeating Win-Draw-Loss Order

You are given a string containing only W, D, and L. Rearrange all characters into rounds. In each round, append at most one remaining W, then one remaining D, then one remaining L, skipping any character whose supply is exhausted. Continue until no characters remain.

Return the resulting string.

Function Signature

def arrange_results(results: str) -> str:
    ...

Constraints

  • 0 <= len(results) <= 1_000_000
  • Every character in results is one of W , D , or L .
  • The output must contain exactly the same multiset of characters as the input.

Examples

Input: results = "WWWLLDDLD"
Output: "WDLWDLWDL"
Input: results = "WLDDL"
Output: "WDLDL"
Input: results = "WWWWLDDL"
Output: "WDLWDLWW"

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Capital One•More Software Engineer•Capital One Software Engineer•Capital One Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.