Re: [闲聊] 每日leetcode

楼主: JerryChungYC (JerryChung)   2024-09-21 15:34:37
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'))
作者: Rushia (みけねこ的鼻屎)   2024-09-21 15:36:00
Nlogn 但这题有限制时间和空间啊
楼主: JerryChungYC (JerryChung)   2024-09-21 15:36:00
等Submit会挡再说 :(
作者: sustainer123 (caster)   2024-09-21 15:40:00
大师
楼主: JerryChungYC (JerryChung)   2024-09-21 16:05:00
看懂递回了 不过这样会比较慢喔

Links booklink

Contact Us: admin [ a t ] ucptt.com