Elements over n/3

Write codeMedium30 min

Your task

Given an integer array a, return all elements that appear strictly more than floor(n/3) times, where n is the array length. Return the answers as a list sorted in ascending order. There can be at most two such elements; return an empty list if none qualify.

Examples

majority_n3(a: list[int]) -> list[int]
Example 1
Inputmajority_n3([3, 2, 3])
Output[3]