Class Solution
-
- All Implemented Interfaces:
public final class Solution392 - Is Subsequence\.
Easy
Given two strings
sandt, returntrueifsis a subsequence oft, orfalseotherwise.A subsequence 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.,
"ace"is a subsequence of <code>"<ins>a</ins>b<ins>c</ins>d<ins>e</ins>"</code> while"aec"is not).Example 1:
Input: s = "abc", t = "ahbgdc"
Output: true
Example 2:
Input: s = "axc", t = "ahbgdc"
Output: false
Constraints:
0 <= s.length <= 100<code>0 <= t.length <= 10<sup>4</sup></code>
sandtconsist only of lowercase English letters.
Follow up: Suppose there are lots of incoming
s, 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 ifthas its subsequence. In this scenario, how would you change your code?
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
Modifier and Type Method Description final BooleanisSubsequence(String s, String t)-
-
Method Detail
-
isSubsequence
final Boolean isSubsequence(String s, String t)
-
-
-
-