result to store the lexicographically ordered numbers.current number as 1.n numbers to the result list.current number to the result list.current * 10 is less than or equal to n, multiply current by 10.current is not the last number in its group (i.e., its last digit is not 9) and current + 1 is less than or equal to n, increment current by 1.current by 10 until the last digit is not 9, then increment current by 1.result list contains n numbers.