Longest Mirror Subsequence
Delete any characters you like from text (possibly none) without reordering the rest, so that what remains reads the same forwards and backwards. Return the largest possible length of what remains. A single character always qualifies, and the empty string gives 0.
Example 1
text "bbabcb"
returns 5
Deleting the c leaves bbabb, which reads the same both ways; nothing longer works.
Example 2
text "abcd"
returns 1
All four characters differ, so only a single character can remain.
Constraints
0 <= len(text) <= 40textholds lowercase letters only
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Dynamic programming problems
- Loot Around the Lantern RingMedium
- Lowest Photo WallMedium
- Lucky Toll TripsMedium
- No Double LeapsMedium
- One Forgiven DayMedium
- Paint the FenceMedium
- Shared Subsequence LengthMedium
- Trading With Rest DaysMedium