pow x n, note negative n
binary search and newton
recursive dfs, use visited flags, note to reset the flag
2d dp using O(n) extra space
binary search on both dimension
update solution