shlogg · Early preview
Md Ariful Haque @mah-shamim

Unique Length-3 Palindromic Subsequences In Strings

We can use an efficient algorithm that leverages prefix and suffix character tracking to count all valid palindromic subsequences in O(n) time complexity.

1930. Unique Length-3 Palindromic Subsequences
Difficulty: Medium
Topics: Hash Table, String, Bit Manipulation, Prefix Sum
Given a string s, return the number of unique palindromes of length three that are a subsequence of s.
Note that even if there are multiple ways to obtain the same subsequence, it is still only counted once.
A palindrome is a string that reads the same forwards and backwards.
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.

For example, "...