386. Lexicographical Numbers
class Solution:
def lexicalOrder(self, n: int) -> List[int]:
strArr = [str(i) for i in range(1,n+1)]
strArr.sort()
return [int(s) for s in strArr]
參考
Custom sorting 排序技巧Last updated
class Solution:
def lexicalOrder(self, n: int) -> List[int]:
strArr = [str(i) for i in range(1,n+1)]
strArr.sort()
return [int(s) for s in strArr]
Last updated