일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- Python Code
- 43. Multiply Strings
- 운영체제
- Convert Sorted List to Binary Search Tree
- Substring with Concatenation of All Words
- Regular Expression
- iterator
- DWG
- data science
- 시바견
- Python Implementation
- t1
- 109. Convert Sorted List to Binary Search Tree
- LeetCode
- 컴퓨터의 구조
- concurrency
- shiba
- 프로그래머스
- 밴픽
- Class
- 715. Range Module
- Generator
- 315. Count of Smaller Numbers After Self
- Python
- 30. Substring with Concatenation of All Words
- 파이썬
- Decorator
- Protocol
- kaggle
- attribute
Archives
- Today
- Total
목록Permutation Sequence (1)
Scribbling
LeetCode: 60. Permutation Sequence
class Solution: def getPermutation(self, n: int, k: int) -> str: def factorial(n): if n == 1: return 1 return n * factorial(n-1) nums = [str(i) for i in range(1, n+1)] if k == 1: return ''.join(nums) k -= 1 ret = '' while k > 0: x = factorial(n-1) if k >= x: quotient = k // x k -= quotient * x ret += nums.pop(quotient) else: ret += nums.pop(0) n -= 1 ret += ''.join(nums) return ret
Computer Science/Coding Test
2021. 9. 24. 15:30