bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Leetcode Problem 392. Is Subsequence

392. Is Subsequence

Leetcode Solutions

Approach: Two-Pointers

  1. Initialize two pointers, left for the s string and right for the t string, starting at 0.
  2. While both pointers are within their respective strings: a. If characters at s[left] and t[right] match, increment left. b. Increment right.
  3. If left equals the length of s, return true as all characters in s have been matched in t.
  4. If the end of t is reached (i.e., right equals the length of t), return false as not all characters in s could be matched.
UML Thumbnail

Approach: Divide and Conquer with Greedy

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...