Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 자연어처리
- github
- Kaggle
- 데이콘
- ubuntu
- 편스토랑
- ChatGPT
- leetcode
- 우분투
- SW Expert Academy
- gs25
- PYTHON
- 더현대서울 맛집
- programmers
- 코로나19
- 백준
- Baekjoon
- AI 경진대회
- hackerrank
- 편스토랑 우승상품
- Git
- 금융문자분석경진대회
- Docker
- 프로그래머스 파이썬
- 캐치카페
- dacon
- 맥북
- 프로그래머스
- Real or Not? NLP with Disaster Tweets
- 파이썬
Archives
- Today
- Total
솜씨좋은장씨
[leetCode] 386. Lexicographical Numbers (Python) 본문
728x90
반응형
Given an integer n, return 1 - n in lexicographical order.
For example, given 13, return: [1,10,11,12,13,2,3,4,5,6,7,8,9].
Please optimize your algorithm to use less time and space. The input size may be as large as 5,000,000.
Solution
class Solution:
def lexicalOrder(self, n: int) -> List[int]:
my_nums = [str(i) for i in range(1, n+1)]
my_nums = list(sorted(my_nums))
return my_nums
'Programming > 코딩 1일 1문제' 카테고리의 다른 글
[leetCode] 342. Power of Four (Python) (0) | 2020.07.24 |
---|---|
[leetCode] 692. Top K Frequent Words (Python) (0) | 2020.07.23 |
[leetCode] 172. Factorial Trailing Zeroes (Python) (0) | 2020.07.21 |
[leetCode] 137. Single Number II (Python) (2) | 2020.07.20 |
[leetCode] 383. Ransom Note (Python) (0) | 2020.07.19 |
Comments