일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- shiba
- Protocol
- 43. Multiply Strings
- Regular Expression
- attribute
- 30. Substring with Concatenation of All Words
- data science
- Substring with Concatenation of All Words
- 109. Convert Sorted List to Binary Search Tree
- 컴퓨터의 구조
- 파이썬
- Generator
- DWG
- concurrency
- Python Implementation
- t1
- iterator
- Convert Sorted List to Binary Search Tree
- 밴픽
- Python Code
- 315. Count of Smaller Numbers After Self
- kaggle
- 운영체제
- Decorator
- LeetCode
- 프로그래머스
- Python
- Class
- 시바견
- 715. Range Module
Archives
- Today
- Total
목록Greedy (1)
Scribbling
LeetCode: 358. Rearrange String k Distance Apart
Greedy solution with heap & deque - append character with 'max frequency' currently - put the appended character to a deque for cool-down from collections import Counter, deque import heapq class Solution: def rearrangeString(self, s: str, k: int) -> str: if k = k: freq, char = q.popleft() if freq >= 1: heapq.heappush(h, (-freq, char)) return ''.join(ret) if len(ret) == len(s) else ""
Computer Science/Algorithms & Data Structures
2023. 3. 10. 23:01