String Subsequence

STRING

Problem

Given two strings s and t, check if s is a subsequence of t. 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).

Examples

isSubsequence("ace", "abcde") // returns true // The string "ace" is a subsequence of "abcde" isSubsequence("aec", "abcde") // returns false // The string "aec" is not a subsequence of "abcde" because // the order of characters is changed isSubsequence("hello", "heyllllo") // returns true // The string "hello" is a subsequence of "heyllllo".
Loading...