leet-code/remove-palindromic-subseque.../sol.rs

12 lines
239 B
Rust
Raw Permalink Normal View History

2022-06-09 14:45:14 +00:00
impl Solution {
pub fn remove_palindrome_sub(s: String) -> i32 {
if s.bytes()
.rev()
.zip(s.bytes())
.all(|(b1, b2)| b1 == b2) {
1
} else {
2
}
}
}