Check whether one string is a subsequence of another.
Given two strings s and t, determine whether s is a subsequence of t.
A string s is a subsequence of t if all characters of s appear in t in the same relative order, but not necessarily contiguously.
Return true if s is a subsequence of t; otherwise return false.
t.s must appear in order.s and t.s is the candidate subsequence.t is the reference string to scan.true if s is a subsequence of t, otherwise false.t.Example 1
Input
s = "abc" t = "ahbgdc"
Output
true
Explanation
You can match 'a', then 'b', then 'c' in order while skipping other characters in t.
Example 2
Input
s = "axc" t = "ahbgdc"
Output
false
Explanation
There is no 'x' in t, so s cannot be formed as a subsequence.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.