Skip to content

Commit afb8a99

Browse files
committed
feat: add rust solution to lc problem: No.1332
No.1332. Remove Palindromic Subsequences
1 parent 7ac15b3 commit afb8a99

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

solution/1300-1399/1332.Remove Palindromic Subsequences/README.md

+20
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,26 @@ func reverse(s string) string {
136136
}
137137
```
138138

139+
### **Rust**
140+
141+
```rust
142+
impl Solution {
143+
pub fn remove_palindrome_sub(s: String) -> i32 {
144+
let mut l = 0;
145+
let mut r = s.len() - 1;
146+
let s: Vec<char> = s.chars().collect();
147+
while l < r {
148+
if s[l] != s[r] {
149+
return 2;
150+
}
151+
l += 1;
152+
r -= 1;
153+
}
154+
1
155+
}
156+
}
157+
```
158+
139159
### **...**
140160

141161
```

solution/1300-1399/1332.Remove Palindromic Subsequences/README_EN.md

+20
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,26 @@ func reverse(s string) string {
126126
}
127127
```
128128

129+
### **Rust**
130+
131+
```rust
132+
impl Solution {
133+
pub fn remove_palindrome_sub(s: String) -> i32 {
134+
let mut l = 0;
135+
let mut r = s.len() - 1;
136+
let s: Vec<char> = s.chars().collect();
137+
while l < r {
138+
if s[l] != s[r] {
139+
return 2;
140+
}
141+
l += 1;
142+
r -= 1;
143+
}
144+
1
145+
}
146+
}
147+
```
148+
129149
### **...**
130150

131151
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
impl Solution {
2+
pub fn remove_palindrome_sub(s: String) -> i32 {
3+
let mut l = 0;
4+
let mut r = s.len() - 1;
5+
let s: Vec<char> = s.chars().collect();
6+
while l < r {
7+
if s[l] != s[r] {
8+
return 2;
9+
}
10+
l += 1;
11+
r -= 1;
12+
}
13+
1
14+
}
15+
}

0 commit comments

Comments
 (0)