A double pointer
This question is two-pointer algorithm to optimize the space complexity of dynamic programming algorithm can also stack with the greedy algorithm to do the (slightly)
Second, dynamic programming
This problem dynamic programming algorithm can be optimized spatial complexity with a double pointer arithmetic, you can also stack with the greedy algorithm to do (slightly)
Third, the depth-first traversal dfs
Full array
Directory
(to be continued)