12 September 2026 · Advanced track
Most-Visited Exhibit
Find the exhibit with the highest total visitor count, breaking ties by fewest contributing visit records.
A museum logs visitor counts for its exhibits throughout the day. You are given a list of visit records, each naming the exhibit and how many visitors arrived at that time, in the order the visits happened. Add up the total visitor count for each exhibit. Return the exhibit with the highest total visitor count. If two or more exhibits are tied for the highest total, return whichever of those exhibits reached its total using the fewest separate visit records.
Constraints
visits has between 1 and 1000 entrieseach exhibit name has between 1 and 30 charactersvisitor_count is a whole number between 0 and 100000
Function signature
def most_visited_exhibit(visits):