@reeclapple What is the worst case time complexity for your BFS + DFS solution?
Posts made by kool
RE: Share two similar Java solution that Accpted by OJ.
Time complexity to generate all combinations of well-formed parentheses.
Generating all combinations of well formed paranthesis is a typical example of catalan numbers. You can use the links at the bottom here if you are not aware of the catalan numbers since they are at the heart of the exercise.
Let time complexity for the generating all combinations of well-formed parentheses is f(n), then
f(n) = g(n) * h(n) where g(n) is the time complexity for calculating nth catalan number, and h(n) is the time required to copy this combination to result array.
Therefore, f(n) = catalan(n) * O(n) which is O(4^n/n^1.5)*(n)). Broadly saying just remember that this is a typical example of catalan number and it's time complexity is similar to how catalan(n) is got.
Further readings in to catalan numbers:
RE: Python O(n) 1 pass in-place solution with explanation
@IWantToPass Have a look at the diagrams here to get a better understanding of it.
RE: Sum of Count of Different bits
It's actually similar to finding total hamming distance.