# leetcode392

1、 Is Subsequence
Given a string s and a string t, check if s is subsequence of t.

You may assume that there is only lower case English letters in both s and t. t is potentially a very long (length ~= 500,000) string, and s is a short string (<=100).

A subsequence of a string is a new string which is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (ie, “ace” is a subsequence of “abcde” while “aec” is not).

Example 1:
s = “abc”, t = “ahbgdc”

Return true.

Example 2:
s = “axc”, t = “ahbgdc”

Return false.

class Solution {
public:
bool isSubsequence(string s, string t) {
int length1=s.size();
int length2=t.size();
int i=0,j=0;
while(i<length1&&j<length2){
if(s[i]==t[j]){
++i;
++j;
}
else
++j;
}
if(i==length1)
return true;
else
return false;
}
};

#### LeetCode 392. Is Subsequence 解题报告

2016-10-01 10:59:14

#### LeetCode 392. Is Subsequence 题解——Java

2017-03-14 22:30:23

#### leetcode -- 392. Is Subsequence 【贪心算法 + 双指针 + 无后效性】

2017-06-17 23:04:17

#### [leetcode] 392. Is Subsequence 解题报告

2016-09-09 14:49:15

#### [LeetCode392]Is Subsequence

2016-09-27 07:14:59

#### Leetcode392: Is Subsequence

2016-09-23 21:42:12

#### leetcode392: Is Subsequence

2016-11-16 20:31:16