Solved LeetCode program · 892 of 1,000
#1224 · Maximum Equal Frequency
Original English source
The numbers is a list of 2, 2, 1, 1, 5, 3, 3, and 5. Keep a shared seen as an empty list of whole numbers. Keep a shared counts as an empty list of whole numbers. Keep a shared incoming of 0. Keep a shared position of 0. Keep a shared high of 0. Keep a shared highcount of 0. Keep a shared singles of 0. Keep a shared distinct of 0. Keep a shared best of 0.
To Seek from spot (a whole number). If spot is more than the last position of seen, set position to -1, return. If item spot of seen is incoming, set position to spot, return. Seek from spot plus 1.
To Survey from spot (a whole number). If spot is more than the last position of counts, return. The tally is item spot of counts. If tally is more than high, set high to tally. If tally is 1, add 1 to singles. Survey from spot plus 1.
To Count from spot (a whole number). If spot is more than the last position of counts, return. If item spot of counts is high, add 1 to highcount. Count from spot plus 1.
To Size from spot (a whole number). If spot is more than the last position of counts, return. Add 1 to distinct. Size from spot plus 1.
The length is 0.
For every spot from 0 to 7.
Add 1 to length. Set incoming to item spot of numbers. Seek from 0. The slot is position. If slot is less than 0, Place incoming into seen, Place 1 into counts. If slot is at least 0, set item slot of counts to item slot of counts plus 1. Set high to 0. Set highcount to 0. Set singles to 0. Set distinct to 0. Survey from 0. Count from 0. Size from 0. The without is length minus 1. The flattened is distinct times (high minus 1). The trimmed is (distinct minus 1) times high. The okay is 0. If high is 1, set okay to 1. If highcount is 1 and without is flattened, set okay to 1. If singles is 1 and without is trimmed, set okay to 1. If okay is 1, set best to length.
Show best.
Expected stdout
7