TikTok Interview Question

Return maximal elements of a list, breaking ties randomly.