Skip to content

Commit 8eefa28

Browse files
committed
feat: update README_EN for ts solution to lc problem: No.0022
1 parent b8cc919 commit 8eefa28

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

solution/0000-0099/0022.Generate Parentheses/README_EN.md

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -148,25 +148,21 @@ func generateParenthesis(n int) (ans []string) {
148148
#### TypeScript
149149

150150
```ts
151-
impl Solution {
152-
pub fn generate_parenthesis(n: i32) -> Vec<String> {
153-
let mut ans = Vec::new();
154-
155-
fn dfs(ans: &mut Vec<String>, l: i32, r: i32, t: String, n: i32) {
156-
if l > n || r > n || l < r {
157-
return;
158-
}
159-
if l == n && r == n {
160-
ans.push(t);
161-
return;
162-
}
163-
dfs(ans, l + 1, r, format!("{}(", t), n);
164-
dfs(ans, l, r + 1, format!("{})", t), n);
151+
function generateParenthesis(n: number): string[] {
152+
function dfs(l, r, t) {
153+
if (l > n || r > n || l < r) {
154+
return;
165155
}
166-
167-
dfs(&mut ans, 0, 0, String::new(), n);
168-
ans
156+
if (l == n && r == n) {
157+
ans.push(t);
158+
return;
159+
}
160+
dfs(l + 1, r, t + '(');
161+
dfs(l, r + 1, t + ')');
169162
}
163+
let ans = [];
164+
dfs(0, 0, '');
165+
return ans;
170166
}
171167
```
172168

0 commit comments

Comments
 (0)