Is Subsequence

Given two strings s and t, return true if s is a subsequence of t, and false otherwise. A subsequence keeps the relative order of characters but does not require contiguity. Pattern focus: LCS. This is a smaller state version of subsequence dynamic programming and is a standard entry point into string DP.

Input Format

s = source string, t = target string

Output Format

true if s is a subsequence of t, otherwise false

Constraints

  • 0 <= s.length, t.length <= 10^5
  • s and t contain lowercase English letters.

Examples

Example 1:

Input:

s = "abc"
t = "ahbgdc"

Output:

true

Explanation:

The characters a, b, c appear in order inside t.

Example 2:

Input:

s = "axc"
t = "ahbgdc"

Output:

false

Explanation:

The character x does not appear in t in the required order.

Loading...
Is Subsequence - Dp Strings DSA Problem