How to create 2d array/list in Python efficiently?
1
2
3
4
5
6
7
8>>> A = [[0] * 3 for _ in range(2)]
>>> A
[[0, 0, 0], [0, 0, 0]]
Not:
>>> A = [0 * 3 for _ in range(2)]
>>> A
[0, 0]Essence of
dfs
: 1254. #Closed Islands
Via dfs template.
1 | // not dfs template. |
1 | // 2nd time FL: still wrnog: not reduce size of dfs |
1 | // 3rd time FL: right |