Skip to content

Commit 203b49c

Browse files
committed
✨ [392]
1 parent 151a2a4 commit 203b49c

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

392/my_solution.js

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* @param {string} s
3+
* @param {string} t
4+
* @return {boolean}
5+
*/
6+
var isSubsequence = function (s, t) {
7+
let sList = s.split(""), tList = t.split(""), i = 0, len = sList.length
8+
9+
// while (sList.length > 0) {
10+
// let currS = sList = shift();
11+
console.log(sList)
12+
console.log(tList)
13+
while (tList.length > 0) {
14+
let currT = tList.shift();
15+
if (sList[0] === currT) {
16+
sList.shift();
17+
}
18+
}
19+
// }
20+
console.log("sList.length")
21+
console.log(sList.length)
22+
23+
return sList.length === 0;
24+
};
25+
26+
let x =
27+
// isSubsequence("abc", "ahbgdc")
28+
isSubsequence("acb", "ahbgdc")
29+
30+
console.log("Result")
31+
console.log(x)

392/solution.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* @param {string} s
3+
* @param {string} t
4+
* @return {boolean}
5+
*/
6+
var isSubsequence = function (s, t) {
7+
let sList = s.split(""), tList = t.split("")
8+
9+
while (tList.length > 0) {
10+
let currT = tList.shift();
11+
if (sList[0] === currT) {
12+
sList.shift();
13+
}
14+
}
15+
16+
return sList.length === 0;
17+
};

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
- [334. Increasing Triplet Subsequence](./334/)
8080
- [338. Counting Bits](./338/)
8181
- [383. Ransom Note](./383/)
82+
- [392. Is Subsequence](./392/)
8283
- [394. Decode String](./394/)
8384
- [412. Fizz Buzz](./412/)
8485
- [417. Pacific Atlantic Water Flow](./417/)
@@ -160,7 +161,7 @@ Batch create:
160161
NOTE: JS IS HERE
161162
-->
162163
```ssh
163-
chapter=283 && mkdir ./$chapter && touch ./$chapter/my_solution.js && touch ./$chapter/solution.js && alias x="node ./$chapter/my_solution.js"
164+
chapter=392 && mkdir ./$chapter && touch ./$chapter/my_solution.js && touch ./$chapter/solution.js && alias x="node ./$chapter/my_solution.js"
164165
```
165166
> then you can use `x` for quick debug.
166167

0 commit comments

Comments
 (0)