#392

Is Subsequence

pupil · 445 · lc easy +26 · verified · 48.9% accepted · 10,780 likes · top 35%

play →

Description

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

Code

1
2
3