Radiant and Dire senators ban each other. Each senator bans the next opposing senator. Determine winning party.

Input: senate="RD" → Output: "Radiant" Input: senate="RDD" → Output: "Dire"

Greedy with two queues: each senator bans the next available opponent. Re-add winners to back of queue.

public String predictPartyVictory(String senate) { Queue<Integer> R = new LinkedList<>(), D = new LinkedList<>(); int n = senate.length(); for (int i = 0; i < n; i++) { if (senate.charAt(i) == 'R') R.add(i); else D.add(i); } while (!R.isEmpty() && !D.isEmpty()) { int r = R.poll(), d = D.poll(); if (r < d) R.add(r + n); else D.add(d + n); } return R.isEmpty() ? "Dire" : "Radiant"; }