You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Given a string s, return the number of unique palindromes of length three that are a subsequence of s.
7
+
8
+
# Note that even if there are multiple ways to obtain the same subsequence, it is still only counted once.
9
+
10
+
# A palindrome is a string that reads the same forwards and backwards.
11
+
12
+
# A subsequence of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of the remaining characters.
13
+
14
+
# For example, "ace" is a subsequence of "abcde".
15
+
16
+
17
+
# Example 1:
18
+
19
+
# Input: s = "aabca"
20
+
# Output: 3
21
+
# Explanation: The 3 palindromic subsequences of length 3 are:
22
+
# - "aba" (subsequence of "aabca")
23
+
# - "aaa" (subsequence of "aabca")
24
+
# - "aca" (subsequence of "aabca")
25
+
# Example 2:
26
+
27
+
# Input: s = "adc"
28
+
# Output: 0
29
+
# Explanation: There are no palindromic subsequences of length 3 in "adc".
30
+
# Example 3:
31
+
32
+
# Input: s = "bbcbaba"
33
+
# Output: 4
34
+
# Explanation: The 4 palindromic subsequences of length 3 are:
0 commit comments