https://leetcode.com/problems/lexicographical-numbers
386. Lexicographical Numbers
思路:不会算复杂度 它答案也没挡 就随便解了
等哪天会挡复杂度再说
Python Code:
class Solution:
def lexicalOrder(self, n: int) -> List[int]:
ln = len(str(n)
return sorted(range(1, n+1), key=lambda x: str(x).ljust(ln, '0'))