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 6fa456c commit ab2111dCopy full SHA for ab2111d
LeetCode/678. Valid Parenthesis String/index.js
@@ -0,0 +1,22 @@
1
+var checkValidString = function(s) {
2
+ let diff = 0;
3
+ for (let i = 0; i < s.length; i++) {
4
+ if (s[i] === '(' || s[i] === '*') diff++
5
+ else diff--
6
+ if (diff < 0) return false;
7
+ }
8
+ if (diff === 0) return true
9
+
10
+ diff = 0;
11
+ for (let i = s.length - 1; i >= 0; i--) {
12
+ if (s[i] === ')' || s[i] === '*') diff++
13
14
15
16
+ return true;
17
+};
18
19
+var checkValidStringV2 = function(s) {
20
21
+ let first = 0, second = s.length - 1;
22
+}
0 commit comments