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