Skip to main content

Dota2 Senate

MediumSorting

Description

Senators in Dota2 from two parties vote to ban opposite party members. Return which party wins when senators vote optimally in circular order.

Examples

Input:senate = "RD"
Output:"Radiant"
Explanation:

Radiant senator R acts first and bans the Dire senator D. Only R remains, so Radiant wins.

Input:senate = "RDDR"
Output:"Radiant"
Explanation:

Round 1: R bans first D (RDDR → RDR), first D bans R (RDR → DR), second R bans second D (DR → R). Round 2: Only R remains, but since Dire had the last active senator before elimination, Dire wins.

Input:senate = "DRDRDR"
Output:"Dire"
Explanation:

Round 1: D bans first R (DRDRDR → DDRDR), first R bans second D (DDRDR → DRDR), second D bans second R (DRDR → DDR), third R bans third D (DDR → DR). This continues alternating until Dire has more remaining senators.

Constraints

  • 1 ≤ senate.length ≤ 10⁴

Ready to solve this problem?

Practice solo and sharpen your skills for technical interviews.