625. Dota2 Senate

MediumStackQueueGreedy

Senators from two parties, 'R' (Radiant) and 'D' (Dire), take turns in a round-based process. In order, each senator may ban the next opposing senator from voting; banned senators are skipped. The process loops until only one party remains. Given the senate string, return the winning party: 'Radiant' or 'Dire'. The input is JSON {senate}.

Input: JSON {senate}.

Output: String — 'Radiant' or 'Dire'.

Examples

Example 1
Input: {"senate":"RD"}
Output: Radiant
Explanation: R bans D first.
Example 2
Input: {"senate":"RDD"}
Output: Dire
Explanation: The two D senators prevail.
Example 3
Input: {"senate":"R"}
Output: Radiant
Explanation: Only Radiant remains.

Constraints

Asked by

AmazonGoogleMetaBloomberg
Solve this problem in the editor →