9 September 2026 · Advanced track
Tallest District Total
Advanced
Dictionaries
Records
Find the district with the highest total building height, breaking ties by the tallest single building.
A city planner logs buildings across several districts. You are given a list of building records, each naming its district and its height, in the order they were recorded. Add up the total height of all buildings in each district. Return the district with the highest total height. If two or more districts are tied for the highest total, return whichever of those districts contains the single tallest building.
Constraints
buildings has between 1 and 1000 entrieseach district name has between 1 and 30 charactersheight is a whole number between 1 and 100000
Function signature
def tallest_total_district(buildings):