Problems > Is It a Subsequence

Is It a Subsequence

Difficulty: 1100 2000 ms 128 MB

strings two-pointers

Is A a subsequence of B — can A be obtained from B by deleting characters without reordering?

Input: two lines: string A, then string B.

Output: YES or NO.

Constraints:

  • 1 ≤ |A|, |B| ≤ 104
  • lowercase letters

Sample Tests

Input 1
ace
abcde
Output 1
YES
Input 2
aec
abcde
Output 2
NO

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.