GonnaTry's blog

By GonnaTry, history, 6 months ago, In English

I was recently solving (https://codeforces.com/contest/1900/problem/C) . I did DFS approach first https://codeforces.com/contest/1900/submission/239489864. But it gave TLE on testcase 5 but when did using BFS 239489864. It got accepted but why? Both are just brute force yet one works not other. Please help

  • Vote: I like it
  • 0
  • Vote: I do not like it

»
6 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by GonnaTry (previous revision, new revision, compare).

»
6 months ago, # |
  Vote: I like it 0 Vote: I do not like it

try passing the string by reference. your code would create a copy of the string upon each dfs call.