- dynamic programing with
f[i][j] =
whethers[i:j+1]
akas[i]..s[j]
is palindrome or its length - enumerate pivots, and expand from each pivot
- if using dynamic programing, in general
f[i][j] = f[i+1][j-1] || f[i][j-1] || f[i+1]f[j]
(meaning you can either take both end, left only, or right only
- be careful with the initial state at the time of initialization
- be careful to explicitly set the default state or negative state while iterating through
f
- Two level nested loop; start a BFS each time when it's an island. Board level visited set. Boundary check on nx ny. 200
Four cases always to consider: 1) node == None 2) leaf node (this one is not necessary but safe to consider) 3) missing left branch 4) missing right branch