Predict Which Faction Wins a Round-Robin Veto Vote

Last updated: November 29, 2026

Quick Overview

Members of two code-review factions, Radiant and Dire, take turns in a fixed order; on their turn a member may veto one opponent, who loses all future turns, and rounds repeat until one faction remains. Given the seating string, return the winning faction if everyone plays optimally.

Google
Coding & Algorithms
Software Engineer
Google
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


Members of two code-review factions, Radiant and Dire, take turns in a fixed order; on their turn a member may veto one opponent, who loses all future turns, and rounds repeat until one faction remains. Given the seating string, return the winning faction if everyone plays optimally.

Google interviewers use this as a test of greedy plus queue simulation: the optimal veto is always the next opponent due to act. They check that you can argue why and simulate in linear time.

What the Interviewer Expects
  • Argue that each member should veto the nearest upcoming opponent
  • Simulate with two queues of indices
  • Re-enqueue the survivor with index plus n for the next round
  • Stop when one queue is empty
  • O(n) amortized time
Key Topics to Cover
Greedy
Queue simulation
Game reasoning
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • Members may also abstain. Does the answer change?
  • Three factions with the same rule.
  • Return the order in which members are vetoed.
  • Some members have two vetoes per turn.
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Input: string of R and D, the turn order. Each living member, in order, vetoes one opponent. The process repeats in rounds. Output: "Radiant" or "Dire"....

High-Level Design

On your turn, the most dangerous opponent is the next one who will act, because they would otherwise veto one of your teammates soon. Vetoing an opponent who acts later is never better: the nearer one...


Submit Your Answer
Markdown supported