Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hojongs/algorithm
A set of source codes to solve algorithm written in python
https://github.com/hojongs/algorithm
algorithm baekjoon leetcode programmers python
Last synced: 12 days ago
JSON representation
A set of source codes to solve algorithm written in python
- Host: GitHub
- URL: https://github.com/hojongs/algorithm
- Owner: hojongs
- Created: 2021-07-07T17:15:22.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-06-01T01:13:43.000Z (over 1 year ago)
- Last Synced: 2023-06-01T02:23:35.785Z (over 1 year ago)
- Topics: algorithm, baekjoon, leetcode, programmers, python
- Language: Python
- Homepage:
- Size: 67.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 153
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Algorithms
## Impressive problems
### DP
- [leetcode/easy/p53.py](https://leetcode.com/problems/maximum-subarray/)
- Tabulation (Bottom-up)
- [leetcode/easy/p70.py](https://leetcode.com/problems/climbing-stairs/)
- Memoization (Top-down)
- [leetcode/easy/p121.py](https://leetcode.com/problems/best-time-to-buy-and-sell-stock/)
- Tabulation (Bottom-up)## Leetcode
https://leetcode.com/problemset/all/
[my account](https://leetcode.com/hojongs/)
## Baekjoon Online Judge
https://www.acmicpc.net/problemset
[my account](https://www.acmicpc.net/user/ssaemo)
### Python tips
Python은 기본적으로 느리다. 이로 인한 시간 초과를 피하기 위해, Python보다는 PyPy를 사용하여 제출하기를 권장한다.
백준 사이트는 IO도 코드에서 직접 처리한다 종종 IO 코드가 시간 초과의 원인이 된다
https://www.acmicpc.net/problem/15552
https://www.acmicpc.net/board/view/22716
https://www.acmicpc.net/blog/view/55
https://www.acmicpc.net/blog/view/70
https://wiki.python.org/moin/TimeComplexity
- input
- sys.stdin.readline() 사용하기 : input() 지양
- 단, readline()은 \n을 포함하므로, 이를 제외하려면 rstrip()을 함께 사용한다
- `*` operator를 사용하여 list 초기화하기
[reference](https://www.geeksforgeeks.org/python-which-is-faster-to-initialize-lists/)
- 수행 시간 2초 이상에서는 영향이 없었다
```python
import sysn = int(sys.stdin.readline())
strs = [0] * n
for i in range(n):
strs[i] = sys.stdin.readline().rstrip()
```
- print() 한 번만 호출하기 : print
- 라고 썼으나, [15552](https://www.acmicpc.net/problem/15552) 에서는 오히려 시간 초과?가 발생했다
```python
output = ''
for s in strs:
output += s + '\n'
print(output)
```
- queue 용도로 list 대신 collections.dequeue 사용하기 [reference](https://www.acmicpc.net/blog/view/70)
- Pypy: print()보다 sys.stdout.write() 사용하여 메모리 절약하기 [reference](https://www.acmicpc.net/blog/view/70)
- Pypy는 재귀에 약하다? [reference](https://www.acmicpc.net/blog/view/70)## Programmers
https://programmers.co.kr/