Skip to content

Commit

Permalink
392
Browse files Browse the repository at this point in the history
  • Loading branch information
lzl124631x committed Mar 2, 2022
1 parent d7ba83a commit 7389706
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 26 deletions.
23 changes: 11 additions & 12 deletions leetcode/392. Is Subsequence/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
# [392. Is Subsequence (Easy)](https://leetcode.com/problems/is-subsequence/)

<p>Given a string <b>s</b> and a string <b>t</b>, check if <b>s</b> is subsequence of <b>t</b>.</p>
<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 subsequence of a string is a new string which is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (ie, <code>"ace"</code> is a subsequence of <code>"abcde"</code> while <code>"aec"</code> is not).</p>

<p><b>Follow up:</b><br>
If there are lots of incoming S, say S1, S2, ... , Sk where k &gt;= 1B, and you want to check one by one to see if T has its subsequence. In this scenario, how would you change your code?</p>

<p><b>Credits:</b><br>
Special thanks to <a href="https://leetcode.com/pbrother/">@pbrother</a> for adding this problem and creating all test cases.</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>&nbsp;</p>
<p><strong>Example 1:</strong></p>
Expand All @@ -23,19 +17,24 @@ Special thanks to <a href="https://leetcode.com/pbrother/">@pbrother</a> for add

<ul>
<li><code>0 &lt;= s.length &lt;= 100</code></li>
<li><code>0 &lt;= t.length &lt;= 10^4</code></li>
<li>Both strings consists only of lowercase characters.</li>
<li><code>0 &lt;= t.length &lt;= 10<sup>4</sup></code></li>
<li><code>s</code> and <code>t</code> consist only of lowercase English letters.</li>
</ul>

<p>&nbsp;</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 &gt;= 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?

**Companies**:
[Adobe](https://leetcode.com/company/adobe), [Amazon](https://leetcode.com/company/amazon), [Google](https://leetcode.com/company/google)

**Related Topics**:
[Binary Search](https://leetcode.com/tag/binary-search/), [Dynamic Programming](https://leetcode.com/tag/dynamic-programming/), [Greedy](https://leetcode.com/tag/greedy/)
[Two Pointers](https://leetcode.com/tag/two-pointers/), [String](https://leetcode.com/tag/string/), [Dynamic Programming](https://leetcode.com/tag/dynamic-programming/)

**Similar Questions**:
* [Number of Matching Subsequences (Medium)](https://leetcode.com/problems/number-of-matching-subsequences/)
* [Shortest Way to Form String (Medium)](https://leetcode.com/problems/shortest-way-to-form-string/)

## Solution 1.
## Solution 1. Two Pointers

```cpp
// OJ: https://leetcode.com/problems/is-subsequence/
Expand Down
14 changes: 0 additions & 14 deletions leetcode/392. Is Subsequence/s1.cpp

This file was deleted.

0 comments on commit 7389706

Please sign in to comment.