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'))