DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
Back to Arena
easy
Two Pointer

Is Subsequence

**Problem Statement:** Given two strings `s` and `t`, return `true` if `s` is a subsequence of `t`, or `false` otherwise. A subsequence of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. **Hint / Expected Approach:** Pointer advances on character match **Edge Cases to Consider:** - (1) Empty s (always true) - (2) Empty t - (3) s longer than t

Examples

Example 1
Input: "abc", "ahbgdc"
Output: True
Example 2
Input: "axc", "ahbgdc"
Output: False
Example 3
Input: "", "ahbgdc"
Output: True

Constraints

  • ▪1 <= data.length <= 10^5
  • ▪Memory complexity must be O(1) or O(k)
  • ▪Ensure non-overlapping pointer access

Watch Out For Edge Cases

  • ▪Empty s (always true)
  • ▪Empty t
  • ▪s longer than t
Frequently Asked At
GoogleAmazonMicrosoftTCS