Skip to main content
LeetCode 649, Medium. Topics: String, Greedy, Queue. View on LeetCode. Generate this problem as a practice environment: tested reference solution, 15 parametrized pytest cases, and a playground notebook:

Problem

In the world of Dota2, there are two parties: the Radiant and the Dire. The Dota2 senate consists of senators from both parties. Voting is a round-based procedure. In each round, each senator (in order) can exercise one right:
  • Ban one senator’s right: make another senator lose all rights in this and all following rounds.
  • Announce the victory: if all senators who still have rights are from the same party, announce victory.
Given a string senate where 'R' is Radiant and 'D' is Dire, predict which party announces victory. Output "Radiant" or "Dire". Every senator plays optimally for their own party.

Examples

Constraints

  • n == senate.length
  • 1 <= n <= 10^4
  • senate[i] is either ‘R’ or ‘D’.

Solution

Reference implementation from solution.py on GitHub, full suite in test_solution.py:

Complexity

Tags

NeetCode 250, NeetCode All.
Last modified on August 25, 2026