Trains the technique from
LeetCode 3005Count Elements With Maximum FrequencyThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A lost-property desk writes one ledger line for every item handed in, and each line records the number of the locker the item was stowed in. lockers[i] is the locker number written on line i, and the same locker number can appear on any number of lines.
Work out the largest number of lines any single locker number holds. Then add up the lines belonging to every locker number that holds exactly that many lines, and return that total.
Example 1
Lockers 45 and 78 hold two lines each, while 91 and 12 hold one each, so two lockers tie at the top and they account for four lines between them.
Example 2
Every locker number holds a single line, so all four numbers tie at the top and all four lines are counted.
Example 3
Locker 56 holds three lines and no other number holds three, so only its three lines are counted.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def peak_locker_lines(lockers: list[int]) -> int:public int peakLockerLines(int[] lockers)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.