Problem 28 of 75

Dota2 Senate

MediumNot solved yetInterview me on this
Before you code · which pattern fits?

The problem

The Dota2 senate consists of Radiant (R) and Dire (D) senators voting in rounds. Each senator can ban one senator from the other party in order. Rounds repeat with the surviving senators until one party remains. All senators play optimally.

Given the string senate, predict which party announces victory: return "Radiant" or "Dire".

"RD" → "Radiant" "RDD" → "Dire"

Your solution runs against 3 unit tests, including edge and large-value cases.

Loading...

Test console · 3 unit tests

Submit your code to run it against all 3 unit tests. Results appear here.

JavaScript, TypeScript & Python run sandboxed in your browser; other languages run on the execution server. Your code is saved locally as you type.

Hint

Reference solution

Video explanation

Dota2 Senate, explainedNeetCodeIO