1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/不同的子序列 [21dk04].html

46 lines
2.1 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给定一个字符串 <code>s</code><strong> </strong>和一个字符串 <code>t</code> ,计算在 <code>s</code> 的子序列中 <code>t</code> 出现的个数。</p>
<p>字符串的一个 <strong>子序列</strong> 是指,通过删除一些(也可以不删除)字符且不干扰剩余字符相对位置所组成的新字符串。(例如,<code>&quot;ACE&quot;</code>&nbsp;&nbsp;<code>&quot;ABCDE&quot;</code>&nbsp;的一个子序列,而&nbsp;<code>&quot;AEC&quot;</code>&nbsp;不是)</p>
<p>题目数据保证答案符合 32 位带符号整数范围。</p>
<p>&nbsp;</p>
<p><strong>示例&nbsp;1</strong></p>
<pre>
<strong>输入:</strong>s = &quot;rabbbit&quot;, t = &quot;rabbit&quot;<code>
<strong>输出</strong></code><strong></strong><code>3
</code><strong>解释:</strong>
如下图所示, 有 3 种可以从 s 中得到 <code>&quot;rabbit&quot; 的方案</code>
<code><strong><u>rabb</u></strong>b<strong><u>it</u></strong></code>
<code><strong><u>ra</u></strong>b<strong><u>bbit</u></strong></code>
<code><strong><u>rab</u></strong>b<strong><u>bit</u></strong></code></pre>
<p><strong>示例&nbsp;2</strong></p>
<pre>
<strong>输入:</strong>s = &quot;babgbag&quot;, t = &quot;bag&quot;
<code><strong>输出</strong></code><strong></strong><code>5
</code><strong>解释:</strong>
如下图所示, 有 5 种可以从 s 中得到 <code>&quot;bag&quot; 的方案</code>
<code><strong><u>ba</u></strong>b<u><strong>g</strong></u>bag</code>
<code><strong><u>ba</u></strong>bgba<strong><u>g</u></strong></code>
<code><u><strong>b</strong></u>abgb<strong><u>ag</u></strong></code>
<code>ba<u><strong>b</strong></u>gb<u><strong>ag</strong></u></code>
<code>babg<strong><u>bag</u></strong></code>
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>0 &lt;= s.length, t.length &lt;= 1000</code></li>
<li><code>s</code><code>t</code> 由英文字母组成</li>
</ul>
<p>&nbsp;</p>
<p><meta charset="UTF-8" />注意:本题与主站 115&nbsp;题相同:&nbsp;<a href="https://leetcode-cn.com/problems/distinct-subsequences/">https://leetcode-cn.com/problems/distinct-subsequences/</a></p>