sorablaze_11's blog

By sorablaze_11, history, 7 years ago, In English

I am solving this problem. And here is the solution. I am using only a simple dfs but it is showing timeout. I am not able to understand why, as time complexity of dfs is O(V + E) and my solution is well within the limits. Can someone help me? Please.

  • Vote: I like it
  • -8
  • Vote: I do not like it

»
7 years ago, # |
  Vote: I like it +3 Vote: I do not like it

It is probably because last parametr of dfs runningSum is taken by value instead of by reference. So for each dfs call new copy of this vector is created.