Skip to content

Commit 0dbc4d3

Browse files
committed
Create 1332.删除回文子序列.js
1 parent ec387e7 commit 0dbc4d3

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

1332.删除回文子序列.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* @param {string} s
3+
* @return {number}
4+
*/
5+
var removePalindromeSub = function(s) {
6+
if (s.length === 0) {
7+
return 0;
8+
} else {
9+
for (let a = 0, b = s.length - 1; a <= b; a++, b--) {
10+
if (s[a] !== s[b]) {
11+
return 2;
12+
}
13+
}
14+
return 1;
15+
}
16+
};

0 commit comments

Comments
 (0)