Back to course home
0% completed
Unique Length-3 Palindromic Subsequences (medium)
Problem Statement
Given a string s
, return the total number of unique palindromes
of length 3
which are subsequences
of s. Even if multiple ways exist to obtain the same subsequence
, it is still only counted once
.
A palindrome
string is a sequence of characters that reads
the same
backward
as forward
.
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.
Examples
Example 1:
- Input: s = "abcba"
- Expected Output: 3
.....
.....
.....
Like the course? Get enrolled and start learning!
Table of Contents
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible