Diwali Offer!Flat 20% OFF
Enroll Now
PrakalpanaLive online tech training

32. Is Subsequence

EasyDay 9 of 60Two Pointers

Given two strings s and t, return true if s is a subsequence of t. A subsequence is formed by deleting zero or more characters from t without changing the order of the rest, so "ace" is a subsequence of "abcde" but "aec" is not.

Example 1
Input: s = "abc", t = "ahbgdc"
Output: true
The letters a, b, c appear in t in this order.
Example 2
Input: s = "axc", t = "ahbgdc"
Output: false
There is no x in t.
Constraints
  • 0 <= s.length <= 100
  • 0 <= t.length <= 10^4
  • Both strings contain only lowercase English letters
Hints
Frequently asked at: Google, Amazon, Paytm, Zoho
Ctrl + Enter runs the examples

Not sure what to learn next?

A 1-on-1 session with an industry mentor and a roadmap built for you. How it works

  1. 1Discuss your goals
  2. 2Get a personal plan
  3. 3Start learning
Book for β‚Ή200/ 30 min