Description
Given two strings s and t, return true if s is a subsequence of t, or false otherwise. A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.
Examples
Input:
s = "abc", t = "ahbgdc"Output:
trueExplanation:
Scanning 'ahbgdc' left to right: find 'a' at index 0, then 'b' at index 2, then 'c' at index 5. All characters of 'abc' found in order.
Input:
s = "axc", t = "ahbgdc"Output:
falseExplanation:
Scanning 'ahbgdc': find 'a' at index 0, but 'x' never appears in the remaining string 'hbgdc'. Since 'x' cannot be found, 'axc' is not a subsequence.
Input:
s = "", t = "ahbgdc"Output:
trueExplanation:
An empty string is a subsequence of any string.
Constraints
- •
0 ≤ s.length ≤ 100 - •
0 ≤ t.length ≤ 10⁴ - •
s and t consist only of lowercase English letters.