We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 29f5618 commit ee11b16Copy full SHA for ee11b16
lib/src/medium/22.generate_parentheses/main.dart
@@ -1,4 +1,9 @@
1
-/// The time and space complexity of this code is `O(4^n / √n)`
+/// The average time and space complexity of this code is `O(4^n / √n)`.
2
+/// This is because we have `2^n` left bracket and `2^(n-1)` right bracket
3
+/// combinations. Here we get `2^n x 2^(n-1) = 4^n`.
4
+/// There are also `√n` invalid combinations with right bracket
5
+/// on the left position and left bracket on the right position.
6
+/// That's why we have to divide `4^n` by `√n`.
7
8
class Solution {
9
List<String> generateParenthesis(int n) {
0 commit comments