A subsequence of a string is what is left after crossing out any number of its letters (possibly none), with the remaining letters kept in their original order. Crossing out r, a and t in "pirate" leaves "pie", so "pie" is a subsequence of "pirate". "epi" is not: the only e comes last.
Given two strings s and t, return true if s is a subsequence of t, and false otherwise.
Counting from 0, t has a t at position 1, an e at 3 and an a at 4: the letters of s, left to right.
Every letter of "mate" appears in t, but the only m is at position 5, and no a comes after it.
A repeated letter needs its own copy in t: both ls are used, one after the other, and then the o. (An empty s is a subsequence of every string: cross out every letter.)
Constraints
0 <= s.length <= 1000 <= t.length <= 10⁴s and t are made of lowercase English letters only.Match the letters of s in order. When a letter of t equals the next letter s still needs, using it straight away is never a mistake: matching early leaves more of t for the rest of s.
true