All problems

Is Subsequence

Easy · two pointers

Given two strings s and t, return True if you can get s by deleting some characters from t (possibly none, possibly all) without changing the order of the characters that are left. Otherwise return False.

For example, "ace" can be made from "abcde" by deleting b and d. But "aec" cannot, because in "abcde" the letter e comes after the c, not before it.

The empty string can always be made from any string, because you can delete every character.

Examples

Example 1

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

Output: True

Delete h, g and d from "ahbgdc" and "abc" is what is left.

Example 2

Input: s = "axc", t = "ahbgdc"

Output: False

There is no "x" in "ahbgdc", so "axc" can never be made.

Example 3

Input: s = "", t = "abc"

Output: True

Delete every character and the empty string is left.

Constraints