Search
⌘K

Leetcode 392. Is Subsequence

Check whether string s can be obtained from t by deleting some characters without reordering (i.e., whether s is a subsequence of t), typically solved with a greedy two-pointer scan in O(|t|+|s|). For many queries, preprocess t (e.g., build a next-occurrence table or char→sorted indices) to answer each s quickly by jumping to the next matching positions.

Asked at:

Meta


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Early February, 2026

Meta

Senior

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. (i.e., "ace" is a subsequence of "abcde" while "aec" is not).

Your account is free and you can post anonymously if you choose.