Rotating Overlapping X-Axis Labels
Harbourline Retail charts headcount by department. Some department names are long enough that their axis labels collide and become unreadable, so the labels are tilted to give each one room. Before the layout is finalised the build script logs which name is the longest, because that name is what decides how much space the axis has to reserve.
Task: Print the department name with the most characters.
Input
The first line holds one integer n, the number of departments. Each of the next n lines holds a department name and its headcount, separated by a single space. Names contain no spaces.
Output
One line holding a single name, exactly as it was read. Length means the number of characters in the name; the headcount plays no part in it. If two names are the longest and tie, print whichever of them appeared first in the input.
Example:
Input:
3
Engineering 50
HR 20
Marketing 30
Output:
Engineering
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in