Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 59c1236

Browse files
update: 97
1 parent 9390bfd commit 59c1236

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ This is the solutions collection of my LeetCode submissions, most of them are pr
6161
| 93 | [Restore IP Addresses](https://leetcode.com/problems/restore-ip-addresses/) | [JavaScript](./src/restore-ip-addresses/res.js) | Medium |
6262
| 94 | [Binary Tree Inorder Traversal](https://leetcode.com/problems/binary-tree-inorder-traversal/) | [TypeScript](./src/binary-tree-inorder-traversal/res.ts) | Easy |
6363
| 96 | [unique-binary-search-trees](https://leetcode.com/problems/unique-binary-search-trees/) | [TypeScript](./src/unique-binary-search-trees/res.ts) | Medium |
64+
| 97 | [interleaving-string](https://leetcode.com/problems/interleaving-string/) | [TypeScript](./src/interleaving-string/res.ts) | Medium |
6465
| 98 | [Validate Binary Search Tree](https://leetcode.com/problems/validate-binary-search-tree/) | [JavaScript](./src/validate-binary-search-tree/res.js) | Medium |
6566
| 100 | [Same Tree](https://leetcode.com/problems/same-tree/) | [JavaScript](./src/same-tree/res.js) | Easy |
6667
| 101 | [Symmetric Tree](https://leetcode.com/problems/symmetric-tree/) | [JavaScript](./src/symmetric-tree/res.js) | Easy |

‎src/interleaving-string/res.ts‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
function isInterleave(s1: string, s2: string, s3: string): boolean {
2+
if (s3.length !== (s2.length+s1.length)) {
3+
return false;
4+
}
5+
6+
if (s3.length == 1) {
7+
return s3 === s2 || s1 === s3;
8+
} else if (s3.length === 0) {
9+
return s1 === s2 && s1 === '';
10+
}
11+
12+
const lastS1 = s1[s1.length-1];
13+
const lastS2 = s2[s2.length-1];
14+
const lastS3 = s3[s3.length-1];
15+
16+
if (lastS3 === lastS1 && isInterleave(s1.slice(0,-1), s2, s3.slice(0,-1), )) {
17+
return true;
18+
}
19+
20+
if (lastS3 === lastS2 && isInterleave(s1, s2.slice(0,-1), s3.slice(0,-1), )) {
21+
return true;
22+
}
23+
24+
return false;
25+
};

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /