Skip to content

Commit 4fad1f2

Browse files
committed
feat: add typescript solution to lc problem: No.0392.Is Subsequence
1 parent 7deab9f commit 4fad1f2

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

solution/0300-0399/0392.Is Subsequence/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,21 @@ class Solution {
8989
}
9090
```
9191

92+
### **TypeScript**
93+
94+
```ts
95+
function isSubsequence(s: string, t: string): boolean {
96+
let m = s.length, n = t.length;
97+
let i = 0;
98+
for (let j = 0; j < n && i < m; ++j) {
99+
if (s.charAt(i) == t.charAt(j)) {
100+
++i;
101+
}
102+
}
103+
return i == m;
104+
};
105+
```
106+
92107
### **C++**
93108

94109
```cpp

solution/0300-0399/0392.Is Subsequence/README_EN.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,21 @@ class Solution {
6464
}
6565
```
6666

67+
### **TypeScript**
68+
69+
```ts
70+
function isSubsequence(s: string, t: string): boolean {
71+
let m = s.length, n = t.length;
72+
let i = 0;
73+
for (let j = 0; j < n && i < m; ++j) {
74+
if (s.charAt(i) == t.charAt(j)) {
75+
++i;
76+
}
77+
}
78+
return i == m;
79+
};
80+
```
81+
6782
### **C++**
6883

6984
```cpp
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
function isSubsequence(s: string, t: string): boolean {
2+
let m = s.length, n = t.length;
3+
let i = 0;
4+
for (let j = 0; j < n && i < m; ++j) {
5+
if (s.charAt(i) == t.charAt(j)) {
6+
++i;
7+
}
8+
}
9+
return i == m;
10+
};

0 commit comments

Comments
 (0)