- leetcode/easy/p53.py
- Tabulation (Bottom-up)
- leetcode/easy/p70.py
- Memoization (Top-down)
- leetcode/easy/p121.py
- Tabulation (Bottom-up)
https://leetcode.com/problemset/all/
https://www.acmicpc.net/problemset
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- ์ํ ์๊ฐ 2์ด ์ด์์์๋ ์ํฅ์ด ์์๋ค
import sys n = int(sys.stdin.readline()) strs = [0] * n for i in range(n): strs[i] = sys.stdin.readline().rstrip()
- sys.stdin.readline() ์ฌ์ฉํ๊ธฐ : input() ์ง์
- print() ํ ๋ฒ๋ง ํธ์ถํ๊ธฐ : print
- ๋ผ๊ณ ์ผ์ผ๋, 15552 ์์๋ ์คํ๋ ค ์๊ฐ ์ด๊ณผ?๊ฐ ๋ฐ์ํ๋ค
output = '' for s in strs: output += s + '\n' print(output)
- queue ์ฉ๋๋ก list ๋์ collections.dequeue ์ฌ์ฉํ๊ธฐ reference
- Pypy: print()๋ณด๋ค sys.stdout.write() ์ฌ์ฉํ์ฌ ๋ฉ๋ชจ๋ฆฌ ์ ์ฝํ๊ธฐ reference
- Pypy๋ ์ฌ๊ท์ ์ฝํ๋ค? reference