Skip to content

Commit c00ff0d

Browse files
authored
Create 1332-remove-palindromic-subsequences.js
1 parent 1fa1b9b commit c00ff0d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* @param {string} s
3+
* @return {number}
4+
*/
5+
const removePalindromeSub = function(s) {
6+
if(s == null || s === '') return 0
7+
if(chk(s)) return 1
8+
return 2
9+
};
10+
11+
function chk(s) {
12+
let l = 0, r = s.length - 1
13+
while(l < r) {
14+
if(s[l] !== s[r]) return false
15+
l++
16+
r--
17+
}
18+
19+
return true
20+
}

0 commit comments

Comments
 (0)