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 bb328ec commit 0b54cd6Copy full SHA for 0b54cd6
README.md
@@ -10,6 +10,8 @@ leetcode 测试
10
11
##### 包含的内容如下
12
13
+https://leetcode.cn/problems/split-a-string-in-balanced-strings/
14
+
15
https://leetcode.cn/problems/maximum-xor-after-operations/
16
17
https://leetcode.cn/problems/construct-binary-tree-from-string/
split-a-string-in-balanced-strings/index.ts
@@ -0,0 +1,16 @@
1
+export default function balancedStringSplit(s: string): number {
2
+ let ans = 0,
3
+ d = 0;
4
+ for (let i = 0; i < s.length; ++i) {
5
+ const ch = s[i];
6
+ if (ch === "L") {
7
+ ++d;
8
+ } else {
9
+ --d;
+ }
+ if (d === 0) {
+ ++ans;
+ return ans;
+}
0 commit comments