Are we sure the DFS will only traverse each node once?
sean46
@sean46
Posts made by sean46

RE: Aren't all these solutions posted here O(n^4)?
You could still get O(N^3) with this approach if you use a set to determine whether all k parts are equal

RE: One line C++
As @john700 said, advancing an iterator past end() is undefined behavior. Here is what I did:
string reverseStr(string s, int k) { for (int front = 0; front < s.size(); front += 2 * k) reverse(s.begin() + front, (front + k >= s.size()) ? s.end() : s.begin() + front + k); return s;

RE: Short O(mn) time O(n) space solution
For the complexity analysis, is my reasoning correct?
O(m * n + (open spaces adjacent to a wall))
Since (open spaces adjacent to a wall) will always be < mn, this solution is O(mn).

RE: Longest Line of Consecutive One in a Matrix
Could you add a comment on how the old/prev work to handle the diagonal case?

RE: Optimal Division
Thanks @vinod23. As @zizhengwu mentioned earlier, can we maybe add some more explanation as to why our solution doesn't have redundant parenthesis?

RE: Optimal Division
Possible to add some more explanation into the complexity analysis for #2?

RE: Friend Circles
For the unionfind complexity analysis: If we traverse over the complete matrix O(n^2) and union/find operations take O(n), wouldn't the complexity be O(n^3)?