516. Longest Palindromic Subsequence Medium
1/**
2 * [516] Longest Palindromic Subsequence
3 *
4 * Given a string s, find the longest palindromic subsequence's length in s.
5 * A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.
6 *
7 * Example 1:
8 *
9 * Input: s = "bbbab"
10 * Output: 4
11 * Explanation: One possible longest palindromic subsequence is "bbbb".
12 *
13 * Example 2:
14 *
15 * Input: s = "cbbd"
16 * Output: 2
17 * Explanation: One possible longest palindromic subsequence is "bb".
18 *
19 *
20 * Constraints:
21 *
22 * 1 <= s.length <= 1000
23 * s consists only of lowercase English letters.
24 *
25 */
26pub struct Solution {}
27
28// problem: https://leetcode.com/problems/longest-palindromic-subsequence/
29// discuss: https://leetcode.com/problems/longest-palindromic-subsequence/discuss/?currentPage=1&orderBy=most_votes&query=
30
31// submission codes start here
32
33impl Solution {
34 pub fn longest_palindrome_subseq(s: String) -> i32 {
35 0
36 }
37}
38
39// submission codes end
40
41#[cfg(test)]
42mod tests {
43 use super::*;
44
45 #[test]
46 fn test_516() {
47 }
48}
49
Back
© 2025 bowen.ge All Rights Reserved.