Skip to main content
All Questions

Find the minimum changes so no two adjacent engineers in a circle choose the same option.

Unlock detailed company stats for this questionUpgrade

Engineers at Uber sit around a circular table playing a modified Rock-Paper-Scissors game. Each engineer secretly chooses 'R', 'P' or 'S'. Two neighbors tie if they choose the same option. You may ask any engineer to change their choice to either of the other two options. Compute the minimum number of engineers whose choice must change so that no two adjacent engineers choose the same option. The table is circular, so the first and last engineers are neighbors. Signature: int minChanges(string choices); choices[i] in {'R','P','S'}, 3 <= n <= 2 * 10^5. Example 1: PRSSP -> 2. Example 2: RRRRRRR -> 4. Example 3: RSPRPSPRS -> 0 (no adjacent engineers choose the same option).

Format · Uber SDE-1 DSA round.

Community answers

No answers contributed by the community yet.

Related courses

Course

Software Engineering Interview Prep

Land your dream software engineering role at Google, Amazon, Microsoft, Meta, Apple, and other top companies. Learn from mock interviews, frameworks, and advice from senior candidates—practice data structures, algorithms, system design, people management, behavioral interviews, and more.

Course

System Design Interviews

Learn how to answer the latest system design questions across product, infrastructure, and AI domains. Features in-depth video examples, written breakdowns, and helpful reference patterns. Watch senior engineers and managers answer these questions in mock interview videos.