Skip to content
Decoder

Is Subsequence

Easy

Problem

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.

Example 1

Input
s = "abc", t = "ahbgdc"
Output
true
Why
a, b, c appear in order

Example 2

Input
s = "axc", t = "ahbgdc"
Output
false
Why
there is no x

Example 3

Input
s = "", t = "abc"
Output
true
Why
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.

Read it once before you touch anything

Want some pressure? Start the timer. In an interview you get about two minutes to understand the problem.

  1. 1Read the goalWhat goes in, what comes out
  2. 2Scan the examplesCheck one by hand
  3. 3Note the constraintsThey set your Big O
Say what it asks in one sentence
Say it out loud first, then compare with ours.