Problem · String
Longest Palindromic Subsequence
Learn this problemProblem statement
Given a string s, return the length of its longest subsequence that reads the same from left to right and right to left.
A subsequence keeps the relative order of selected characters but does not need to use contiguous positions.
Function
longestPalindromeSubseq(s: String) → intExamples
Example 1
s = "bbbab"return = 4One longest palindromic subsequence is bbbb.
Example 2
s = "cbbd"return = 2More Amazon problems
- Secure Maximum DeliveriesOA · Seen Jul 2026
- Find Median from Data StreamONSITE INTERVIEW · Seen Jul 2026
- Handwritten SigmoidPHONE SCREEN · Seen Jul 2026
- Handwritten SoftmaxPHONE SCREEN · Seen Jul 2026
- Koko Eating BananasONSITE INTERVIEW · Seen Jul 2026
- Loyal Customers Across Two DaysONSITE INTERVIEW · Seen Jul 2026
- Maximum System Memory CapacityOA · Seen Jul 2026
- Package Delivery SystemOA · Seen Jul 2026