leaders to store pairs of (leader, time).vote_counts to keep track of the number of votes for each candidate.current_leader to -1 and max_votes to 0.persons and times:
a. Increment the vote count for the current person.
b. If the current person's vote count is greater than or equal to max_votes, update current_leader and max_votes.
c. Append the pair (current_leader, times[i]) to leaders if the leader changes.q(t):
a. Perform a binary search on leaders to find the rightmost pair where time is less than or equal to t.
b. Return the leader from the found pair.