Back to course home
0% completed
Vote For New Content
Is Subsequence (easy)
Problem Statement
Given two strings s
and t
, return true
if the string s
is a subsequence
of the string t
. Otherwise, return false
.
A subsequence
of a string is a new string that can be formed
from the original string
by eliminating some
(can be zero) of the characters without changing
the order
of the remaining characters.
Examples
-
Example 1:
- Input:
s = "hello"
,t = "xyhealoloo"
- Expected Output: true
- Justification: By removing "x", "y", "a", "o", and the second "o" from
t
,s
can be obtained while maintaining the original order.
- Input:
-
Example 2:
- Input:
s = "axc"
,t = "ahbgdc"
- Expected Output: false
- Justification: There is no way to remove characters from
t
to achieves
without altering the sequence of "axc".
- Input:
-
Example 3:
- Input:
s = "abc"
,t = "aabc"
- Expected Output: true
- Justification: By removing the first "a" in
t
,s
is formed while preserving the character sequence.
- Input:
Try it yourself
Try solving this question here:
Python3
Python3
. . . .
.....
.....
.....
Like the course? Get enrolled and start learning!
Table of Contents
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible