1 <= n <= 5 * 104
Python源码:
class Solution:
def lexicalOrder(self, n: int) -> List[int]:
list_n = []
for i in range(1, n+1):
list_n.append(str(i))
sorted_list = sorted(list_n)
l = len(sorted_list)
result = []
for i in range(l):
result.append(int(sorted_list[i]))
return result