Given two different lists of non-negative integers, return the list that has the highest maximum (e.g. [4, 2], [3, 3, 1] -> [4, 2]
).
If they both have the same maximum, return the list that contains more instances of this maximum (e.g. [4, 2, 4], [4, 3, 3, 3, 1, 3] -> [4, 2, 4]
).
If, after these comparisons, they are equal, do the same comparison but with their next highest item (e.g. [2, 3, 4, 4], [4, 4, 3, 3, 1] -> [4, 4, 3, 3, 1]
).
If, after all these comparisons, they are still considered to be equal, output the longer list (e.g. [4, 3, 2, 1, 0], [1, 2, 3, 4] -> [4, 3, 2, 1, 0]
).
Make your code as short as possible.
Test Cases
[4, 4, 4, 4, 2, 4], [4, 4, 4, 4, 3, 2] -> [4, 4, 4, 4, 2, 4]
[0], [] -> [0]
[0, 0], [0] -> [0, 0]
[1], [0, 0] -> [1]
[4, 4, 4, 4, 4, 2], [4, 4, 4, 4, 4] -> [4, 4, 4, 4, 4, 2]
[1, 0], [0, 0, 0] -> [1, 0]