If a value fills more than half of a list, then once the list is sorted the element exactly in the middle must be it: a block longer than half covers the middle wherever it sits. Some questions come down to looking at a single index after sorting.
ordered = sorted(scores, reverse=True)rank = 0while rank < len(ordered) and ordered[rank] > rank:rank += 1return rank
Sorting is not always the fastest way, and it is nearly always the easiest correct one. Solve by sorting first and see it pass; then ask "could I do it in one pass, without sorting?". For the majority element the answer is yes: a candidate and a counter are enough.