Click here to see the full article post
@Aeonaxx I have updated it. THanks.
For the first approach's time complexity, better say O(4N) instead of redefining n (to what N already is).
Approach #2 is definitely wrong. We should do modulo operation on result. After modified, it'll still get TLE.
@Apolloliu I have updated the Approach #2. Its now AC. Thanks
A remainder, the author uses int type, you must do the mode for every DFS return value, otherwise the total summation may overflow cause weird wrong result. You can use long type to avoid this kind of problem.
@tony407 So how would you do it with long, exactly?
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.