mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
23 lines
1.4 KiB
HTML
23 lines
1.4 KiB
HTML
<p>Given two strings <code>s</code> and <code>t</code>, return <code>true</code><em> if </em><code>s</code><em> is a <strong>subsequence</strong> of </em><code>t</code><em>, or </em><code>false</code><em> otherwise</em>.</p>
|
|
|
|
<p>A <strong>subsequence</strong> of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (i.e., <code>"ace"</code> is a subsequence of <code>"<u>a</u>b<u>c</u>d<u>e</u>"</code> while <code>"aec"</code> is not).</p>
|
|
|
|
<p> </p>
|
|
<p><strong>Example 1:</strong></p>
|
|
<pre><strong>Input:</strong> s = "abc", t = "ahbgdc"
|
|
<strong>Output:</strong> true
|
|
</pre><p><strong>Example 2:</strong></p>
|
|
<pre><strong>Input:</strong> s = "axc", t = "ahbgdc"
|
|
<strong>Output:</strong> false
|
|
</pre>
|
|
<p> </p>
|
|
<p><strong>Constraints:</strong></p>
|
|
|
|
<ul>
|
|
<li><code>0 <= s.length <= 100</code></li>
|
|
<li><code>0 <= t.length <= 10<sup>4</sup></code></li>
|
|
<li><code>s</code> and <code>t</code> consist only of lowercase English letters.</li>
|
|
</ul>
|
|
|
|
<p> </p>
|
|
<strong>Follow up:</strong> Suppose there are lots of incoming <code>s</code>, say <code>s<sub>1</sub>, s<sub>2</sub>, ..., s<sub>k</sub></code> where <code>k >= 10<sup>9</sup></code>, and you want to check one by one to see if <code>t</code> has its subsequence. In this scenario, how would you change your code? |