Skip to content

Is Subsequence

EasyTwo Pointers
Decode it first. Clues, constraints, pattern and plan before any code.

Given two strings s and t, return true if s is a subsequence of t. A subsequence is what you get by deleting zero or more characters from t without changing the order of the characters that remain.

s = "abc", t = "ahbgdc"   →  true    (a, b, c appear in order)
s = "axc", t = "ahbgdc"   →  false   (there is no x)
s = "",    t = "abc"      →  true    (the empty string is a subsequence of anything)

Constraints

  • 0 <= s.length <= 100
  • 0 <= t.length <= 10^4
  • s and t contain only lowercase English letters.