Problem
You get two strings, s and t. Return true if s is a subsequence of t. Return false otherwise.
A subsequence of a string is the string that remains after you delete zero or more characters. The remaining characters keep their order. For example, "cat" is a subsequence of "coast", but "tac" is not.
Example 1
- Input:
- s = "ran", t = "rotation"
- Output:
- true
- Explanation:
- The characters of
sappear intat indexes 0, 3 and 7, in the same order.
Example 2
- Input:
- s = "dog", t = "good"
- Output:
- false
- Explanation:
thas the charactersd,oandg, but not in this order.
Example 3
- Input:
- s = "", t = "abc"
- Output:
- true
- Explanation:
- An empty string is a subsequence of every string.
Constraints
- 0 <= s.length <= 100
- 0 <= t.length <= 10^4
- s and t have only lowercase English letters.
Follow-up
Suppose that you must check a very large number of strings s against the same t. How can you make each check fast?
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
Meta
Leetcode 392. Is Subsequence
Reported Feb 2, 2026 · 1 source report
SENIOR
Source snapshot: Nov 12, 2026
View source