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
- Docker
- dacon
- gs25
- PYTHON
- ChatGPT
- programmers
- 프로그래머스 파이썬
- 파이썬
- github
- Git
- 편스토랑 우승상품
- 편스토랑
- 금융문자분석경진대회
- 자연어처리
- hackerrank
- 데이콘
- 프로그래머스
- 캐치카페
- 코로나19
- leetcode
- 백준
- ubuntu
- AI 경진대회
- SW Expert Academy
- Real or Not? NLP with Disaster Tweets
- Kaggle
- 맥북
- Baekjoon
- 더현대서울 맛집
- 우분투
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