Easy

Quiz

#392 Is Subsequence

APPROACH

Given strings s and t, determine whether s is a subsequence of t. A subsequence maintains relative order but need not be contiguous: for instance, "ace" is a subsequence of "abcde", but "aec" is not.

Return true if s is a subsequence of t, or false otherwise.

Example 1:

Input: s = "abc", t = "ahbgdc"
Output: true

Example 2:

Input: s = "axc", t = "ahbgdc"
Output: false
1 of 4
1:00

What is the optimal approach for this problem?