Lexicographical Order String Leetcode Questions Java