Premium problem90. City Offering the Most Amenities

Medium Locked

listings has columns listing_id, city and amenities, where amenities is a comma-separated string such as "wifi,kitchen,pool". A listing with no amenities holds the empty string.

Count every amenity mentioned across all listings in each city, counting repeats across listings, and return the name of the city with the highest total as a string. If two cities tie, return whichever comes first alphabetically.

Input

   listing_id    city        amenities
0           1   Paris     wifi,kitchen
1           2   Paris             pool
2           3  Lisbon             wifi
3           4  Lisbon  kitchen,pool,tv

Output

'Lisbon'

Premium problem

This one's part of Premium. Unlock the full Pandas track plus every other premium problem on the site.

Implement solve(...)