Solvarch
DSA ProblemsProgressPlanRoadmapsReviewCheat SheetsCompaniesSystem DesignCS FundamentalsQuestion Bank
Theme
Problems

Is Subsequence

Easy
two-pointersstringgreedy

Given strings s and t, return true if s is a subsequence of t — i.e. s can be formed by deleting characters of t without reordering the rest.

Input

  • Line 1: string s
  • Line 2: string t

Output: true or false.

Example 1
Input:
abc
ahbgdc
Output:
true
Example 2
Input:
axc
ahbgdc
Output:
false

Constraints

  • 0 ≤ s.length ≤ 100
  • 0 ≤ t.length ≤ 10^4
  • Lowercase English letters only.
Watch a video walkthrough

Run your code against the sample tests, or Submit to run the full suite.