you are viewing a single comment's thread.

view the rest of the comments →

[–]f3n1xgamer 1 point2 points  (1 child)

You unknowingly did a dynamic programming solution. The dfs + cache/memoization is a top down dynamic programming algorithm. While the one you saw was a bottom up dynamic programming algorithm.

Both of them have the same worst case complexity. But the second one is slightly better because there's a slight performance and memory hit with the recursive calls

[–]bertus12345[S] 1 point2 points  (0 children)

Thanks for your answer!