Class Solution

  • All Implemented Interfaces:

    
    public final class Solution
    
                        

    392 - Is Subsequence\.

    Easy

    Given two strings s and t, return true if s is a subsequence of t, or false otherwise.

    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 &lt;= s.length &lt;= 100

    • <code>0 <= t.length <= 10<sup>4</sup></code>

    • s and t consist 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 if t has its subsequence. In this scenario, how would you change your code?

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      Solution()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Boolean isSubsequence(String s, String t)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait