Description
https://leetcode.com/problems/combination-sum/description/
Solution
BFS
The naive implementation of BFS, in this algorithm, we need a lot of space to record the state, and the time spent on copying these states is tremendous.
1 | class Solution(object): |
DFS
1 | class Solution(object): |
Non_Recursive Solution(DFS)
1 | class Solution(object): |
But the result is upsetting, the recursive method performs better than the non-recursive solution.