Skip to content

Commit c61435c

Browse files
committed
Time: 4 ms (6.3%), Space: 55.7 MB (50.42%) - LeetHub
source:7ce828fa92598b751ead5360a569da5769fb2d7e
1 parent d6b278d commit c61435c

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* @param {string} s
3+
* @param {string} t
4+
* @return {boolean}
5+
*/
6+
var isSubsequence = function(s, t) {
7+
if (s.length === 0) return true;
8+
9+
let sIdx = 0;
10+
11+
for (let tIdx = 0; tIdx < t.length; tIdx++) {
12+
if (s[sIdx] === t[tIdx]) {
13+
sIdx++;
14+
}
15+
if (sIdx === s.length) return true;
16+
}
17+
return false;
18+
19+
};

0 commit comments

Comments
 (0)