Skip to content

Commit a4c18c7

Browse files
authored
Update 1332.remove-palindromic-subsequences.md
添加Java代码
1 parent 3fa48ac commit a4c18c7

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

problems/1332.remove-palindromic-subsequences.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ s 仅包含字母 'a'  和 'b'
7272

7373
## 代码
7474

75-
代码支持:Python3
75+
代码支持:Python3、Java
7676

7777
Python3 Code:
7878

@@ -107,6 +107,21 @@ class Solution:
107107

108108
```
109109

110+
Java Code:
111+
```java
112+
class Solution {
113+
public int removePalindromeSub(String s) {
114+
if ("".equals(s)) {
115+
return 0;
116+
}
117+
if (s.equals(new StringBuilder(s).reverse().toString())) {
118+
return 1;
119+
}
120+
return 2;
121+
}
122+
}
123+
```
124+
110125
**复杂度分析**
111126
- 时间复杂度:$O(N)$
112127
- 空间复杂度:$O(1)$

0 commit comments

Comments
 (0)