Back to DSA sheet
Is Subsequence
EasyArraysGiven two strings s and t, return whether s is a subsequence of t. A subsequence keeps the original order but may skip characters of t.
Input format (stdin): the first line is s, the second line is t. Output true or false. (s may be empty, shown as a blank first line.)
Examples
Input: abc
ahbgdc
Output: true
a, b, c appear in order inside t.
Input: axc
ahbgdc
Output: false
x does not appear after a.
Constraints
- 0 <= |s| <= 100
- 0 <= |t| <= 10^4
Sheets
NeetCode 250
is-subsequence.cpp3 sample tests
Loading editor
Test results
Run the sample tests to check your solution against expected output.
Custom input (stdin)
Output
Run your code to see its output.