Sorting Three Groups Leetcode