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

38 lines
1.5 KiB
HTML
Raw Normal View History

2023-12-09 18:42:21 +08:00
<p>给你两个字符串 <code>s</code><strong> </strong><code>t</code> ,统计并返回在 <code>s</code><strong>子序列</strong><code>t</code> 出现的个数,结果需要对&nbsp;10<sup>9</sup> + 7 取模。</p>
2022-03-27 20:56:26 +08:00
2023-12-09 18:42:21 +08:00
<p>&nbsp;</p>
2022-03-27 20:56:26 +08:00
2023-12-09 18:42:21 +08:00
<p><strong>示例&nbsp;1</strong></p>
2022-03-27 20:56:26 +08:00
<pre>
<strong>输入:</strong>s = "rabbbit", t = "rabbit"<code>
<strong>输出</strong></code><strong></strong><code>3
</code><strong>解释:</strong>
2023-12-09 18:42:21 +08:00
如下所示, 有 3 种可以从 s 中得到 <code>"rabbit" 的方案</code>
2022-03-27 20:56:26 +08:00
<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>
2023-12-09 18:42:21 +08:00
<p><strong>示例&nbsp;2</strong></p>
2022-03-27 20:56:26 +08:00
<pre>
<strong>输入:</strong>s = "babgbag", t = "bag"
<code><strong>输出</strong></code><strong></strong><code>5
</code><strong>解释:</strong>
2023-12-09 18:42:21 +08:00
如下所示, 有 5 种可以从 s 中得到 <code>"bag" 的方案</code>
2022-03-27 20:56:26 +08:00
<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>
2023-12-09 18:42:21 +08:00
<p>&nbsp;</p>
2022-03-27 20:56:26 +08:00
<p><strong>提示:</strong></p>
<ul>
2023-12-09 18:42:21 +08:00
<li><code>1 &lt;= s.length, t.length &lt;= 1000</code></li>
2022-03-27 20:56:26 +08:00
<li><code>s</code><code>t</code> 由英文字母组成</li>
</ul>