Movatterモバイル変換


[0]ホーム

URL:


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

Commitc6c73f2

Browse files
committed
update: 139
1 parent3918d8e commitc6c73f2

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ This is the solutions collection of my LeetCode submissions, most of them are pr
8787
| 135|[Candy](https://leetcode.com/problems/candy/)|[JavaScript](./src/candy/res.js)| Hard|
8888
| 136|[Single Number](https://leetcode.com/problems/single-number/)|[JavaScript](./src/single-number/res.js)| Easy|
8989
| 137|[Single Number II](https://leetcode.com/problems/single-number-ii/)|[JavaScript](./src/single-number-ii/res.js)| Medium|
90+
| 139|[word-break](https://leetcode.com/problems/word-break/)|[TypeScript](./src/word-break/res.ts)| Medium|
9091
| 151|[Reverse Words in a String](https://leetcode.com/problems/reverse-words-in-a-string/)|[JavaScript](./src/reverse-words-in-a-string/res.js)| Medium|
9192
| 152|[Maximum Product Subarray](https://leetcode.com/problems/maximum-product-subarray/)|[JavaScript](./src/maximum-product-subarray/res.js)| Medium|
9293
| 153|[Find Minimum in Rotated Sorted Array](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/)|[JavaScript](./src/find-minimum-in-rotated-sorted-array/res.js)| Medium|

‎src/word-break/res.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
functionwordBreak(s:string,wordDict:string[]):boolean{
2+
if(!s){
3+
returntrue;
4+
}
5+
constn=s.length;
6+
constdp=newArray(n+1).fill(false);
7+
dp[0]=true;
8+
9+
for(leti=0;i<n;i++){
10+
for(letj=i+1;j<=n+1;j++){
11+
if(dp[i]&&wordDict.includes(s.slice(i,j))){
12+
dp[j]=true;
13+
}
14+
}
15+
}
16+
17+
returndp[n];
18+
};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp