Great optimization. Thx for sharing!
Posts made by eric_haibin_lin
RE: My C++ bi-directional BFS solution (O(N) time, O(N) space), 64ms
RE: Share my simple NON-recursive solution, O(1) space complexity!
Yeah, agreed with @ningli that the algorithm visit each node at most twice.
RE: Easy DP solution in C++ with detailed explanations (8ms, O(n^2) time and O(n) space)
Nice solution! The use of
maxsizevariable is ambiguous at the first sight - it actually means the width of the square instead of the area of the square.
Thanks for sharing!