Skip to content

Commit d9fcfd4

Browse files
committed
Time: 65 ms (91.59%), Space: 42.2 MB (46.55%) - LeetHub
1 parent f2205a1 commit d9fcfd4

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

392-is-subsequence/392-is-subsequence.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@
55
*/
66
var isSubsequence = function(s, t) {
77
let i =0, j =0;
8-
while(i< s.length){
9-
if(j >= t.length) return false;
10-
if(s[i] === t[j]){
11-
i++; j++
12-
}else{
13-
j++
14-
}
8+
while(j<t.length){
9+
if(s[i] === t[j]) {i++};
10+
11+
j++
1512
}
16-
return true;
13+
return i === s.length
14+
1715
};

0 commit comments

Comments
 (0)