Grokking Google Coding Interview
Ask Author
Back to course home

0% completed

Vote For New Content
Is Subsequence (easy)
On this page

Problem Statement

Examples

Try it yourself

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.
  • Example 2:

    • Input: s = "axc", t = "ahbgdc"
    • Expected Output: false
    • Justification: There is no way to remove characters from t to achieve s without altering the sequence of "axc".
  • 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.

Try it yourself

Try solving this question here:

Python3
Python3

. . . .

.....

.....

.....

Like the course? Get enrolled and start learning!

On this page

Problem Statement

Examples

Try it yourself