Fall SalePremium questions, over 25% offUnlock all premium questions for over 25% off
Minimum Adjacent Swaps for Ball Grouping
Medium
Question
A row of colored balls is written as a string balls, one character per ball: 'R' stands for a red ball and 'W' for a white one. A single move exchanges two balls that sit next to each other, and no other kind of move is allowed. Find the fewest moves needed so that every red ball ends up in one unbroken block. If the red balls already form such a block, the answer is 0.
...
Asked at:Microsoft
More Microsoft interview questions
- Office Gift Delivery Schedulerhard
- Group Elements by Common Propertiesmedium
- Largest Shared BST Valuemedium
- Minimum Coins to Cover All Amountsmedium
- Recent Search History Systemhard
- Count Distinct Elements in Each Windoweasy
- Largest Tree Root IDmedium
- Employee Shift Timeline Intervalsmedium
OfferRetriever
Master technical interviews with real questions from top companies. Build your confidence and career.
LEGAL
© 2026 Purple Business Holdings LLC. All rights reserved. See Terms of Service.