Given a non-empty list of integers between 1 and 9 inclusive, find the longest contiguous sublist such that the number of occurrences of each element (of the sublist) within the sublist is equal (not the number of consecutive occurrences, just the total count). You may return any non-empty subset of the solutions.
Examples
Input -> Output
1, 2, 3 [1, 2, 3]
1, 2, 2, 3, 3, 4 [2, 2, 3, 3]
1, 2, 3, 3, 4, 4, 3, 3, 2, 1 [3, 3, 4, 4], [3, 4, 4, 3], [4, 4, 3, 3]
1, 1, 1, 1, 1 [1, 1, 1, 1, 1]
1, 2, 3, 2, 1 [1, 2, 3], [3, 2, 1]
1, 2, 3, 4, 4, 3 [1, 2, 3, 4], [3, 4, 4, 3]
3, 2, 3, 4, 4, 3 [3, 4, 4, 3]
- this is code-golf, so the shortest code in bytes wins
- Standard Loopholes are forbidden, as usual
- I/O may be in any reasonable format. You can do I/O with a string of digits since all inputs will be between 1 and 9, for example (this is mostly to allow regex solutions if anyone can figure that out).