Problem
A senate has senators from two parties, Radiant and Dire. The string senate lists the senators in order. The character R is a Radiant senator, and D is a Dire senator.
The senators act in rounds. In each round, each senator who still has rights acts one time, in the order of senate. A senator without rights does nothing.
When a senator acts, the senator can ban one other senator. A banned senator loses all rights in the current round and in all later rounds.
When all senators with rights are from one party, that party wins. Each senator makes the best choice for their own party. Return "Radiant" or "Dire", the name of the party that wins.
Example 1
- Input:
- senate = "RRDDD"
- Output:
- "Radiant"
- Explanation:
- Senators 0 and 1 ban senators 2 and 3. Senator 4 bans senator 0. Then senator 1 bans senator 4, and Radiant wins.
Example 2
- Input:
- senate = "DRDRR"
- Output:
- "Dire"
- Explanation:
- Senators 0 and 2 ban senators 1 and 3. Senator 4 bans senator 0. Then senator 2 bans senator 4, and Dire wins.
Constraints
- n == senate.length
- 1 <= n <= 10^4
- senate[i] is 'R' or 'D'.
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 649. Dota2 Senate
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source