Skip to content

Commit d7ae047

Browse files
committed
Create README - LeetHub
1 parent e1e243c commit d7ae047

File tree

1 file changed

+51
-0
lines changed
  • 2059-unique-length-3-palindromic-subsequences

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<h2><a href="https://leetcode.com/problems/unique-length-3-palindromic-subsequences">2059. Unique Length-3 Palindromic Subsequences</a></h2><h3>Medium</h3><hr><p>Given a string <code>s</code>, return <em>the number of <strong>unique palindromes of length three</strong> that are a <strong>subsequence</strong> of </em><code>s</code>.</p>
2+
3+
<p>Note that even if there are multiple ways to obtain the same subsequence, it is still only counted <strong>once</strong>.</p>
4+
5+
<p>A <strong>palindrome</strong> is a string that reads the same forwards and backwards.</p>
6+
7+
<p>A <strong>subsequence</strong> 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.</p>
8+
9+
<ul>
10+
<li>For example, <code>&quot;ace&quot;</code> is a subsequence of <code>&quot;<u>a</u>b<u>c</u>d<u>e</u>&quot;</code>.</li>
11+
</ul>
12+
13+
<p>&nbsp;</p>
14+
<p><strong class="example">Example 1:</strong></p>
15+
16+
<pre>
17+
<strong>Input:</strong> s = &quot;aabca&quot;
18+
<strong>Output:</strong> 3
19+
<strong>Explanation:</strong> The 3 palindromic subsequences of length 3 are:
20+
- &quot;aba&quot; (subsequence of &quot;<u>a</u>a<u>b</u>c<u>a</u>&quot;)
21+
- &quot;aaa&quot; (subsequence of &quot;<u>aa</u>bc<u>a</u>&quot;)
22+
- &quot;aca&quot; (subsequence of &quot;<u>a</u>ab<u>ca</u>&quot;)
23+
</pre>
24+
25+
<p><strong class="example">Example 2:</strong></p>
26+
27+
<pre>
28+
<strong>Input:</strong> s = &quot;adc&quot;
29+
<strong>Output:</strong> 0
30+
<strong>Explanation:</strong> There are no palindromic subsequences of length 3 in &quot;adc&quot;.
31+
</pre>
32+
33+
<p><strong class="example">Example 3:</strong></p>
34+
35+
<pre>
36+
<strong>Input:</strong> s = &quot;bbcbaba&quot;
37+
<strong>Output:</strong> 4
38+
<strong>Explanation:</strong> The 4 palindromic subsequences of length 3 are:
39+
- &quot;bbb&quot; (subsequence of &quot;<u>bb</u>c<u>b</u>aba&quot;)
40+
- &quot;bcb&quot; (subsequence of &quot;<u>b</u>b<u>cb</u>aba&quot;)
41+
- &quot;bab&quot; (subsequence of &quot;<u>b</u>bcb<u>ab</u>a&quot;)
42+
- &quot;aba&quot; (subsequence of &quot;bbcb<u>aba</u>&quot;)
43+
</pre>
44+
45+
<p>&nbsp;</p>
46+
<p><strong>Constraints:</strong></p>
47+
48+
<ul>
49+
<li><code>3 &lt;= s.length &lt;= 10<sup>5</sup></code></li>
50+
<li><code>s</code> consists of only lowercase English letters.</li>
51+
</ul>

0 commit comments

Comments
 (0)