easyTwo PointersPure DSA~12 min
Telemetry Subsequence Check
A required sequence of telemetry events must appear in order (not necessarily contiguously) within the recorded event stream. Verify the required sequence is a subsequence of the recording.
Problem
Given two strings s and t, return true if s is a subsequence of t. A subsequence keeps relative order but may skip characters of t.
Input
Two strings s and t (0 ≤ |s| ≤ 100, 0 ≤ |t| ≤ 10^4).
Output
A boolean — true if s is a subsequence of t.
Constraints
- Characters of s must appear in t in the same order
- Empty s is always a subsequence
- Lowercase English letters
Examples
Example 1
Input
s = "abc", t = "ahbgdc"
Output
true
a…b…c appear in order within t.
Example 2
Input
s = "axc", t = "ahbgdc"
Output
false
There is no 'x' in t after 'a'.