← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
Implement a simplified in-memory leader election service that behaves like etcd’s Raft-based election. You will receive a sequence of events over time: node startup, node crash, and explicit leader failure reports. Your task is to maintain the current leader and report it after every event. All nodes are ordered by their numeric id; the smallest live id has the highest priority. When the current leader crashes or is reported failed, elect the next highest-priority live node. If a node recovers (re-starts) it rejoins the pool of candidates. You must handle the following event types:
After every event output the current leader (live node with smallest id) or "-1" if no leader can be elected (cluster empty or all nodes down).