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

Commit5d8872f

Browse files
committed
update: 38
1 parent8094a7e commit5d8872f

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ This is the solutions collection of my LeetCode submissions, most of them are pr
3333
| 33|[Search in Rotated Sorted Array](https://leetcode.com/problems/search-in-rotated-sorted-array/)|[JavaScript](./src/search-in-rotated-sorted-array/res.js)| Medium|
3434
| 34|[Search for a Range](https://leetcode.com/problems/search-for-a-range/)|[JavaScript](./src/search-for-a-range/res.js)| Medium|
3535
| 35|[Search Insert Position](https://leetcode.com/problems/search-insert-position/)|[JavaScript](./src/search-insert-position/res.js)| Easy|
36+
| 38|[count-and-say](https://leetcode.com/problems/count-and-say/)|[TypeScript](./src/count-and-say/res.ts)| Medium|
3637
| 39|[Combination Sum](https://leetcode.com/problems/combination-sum/)|[JavaScript](./src/combination-sum/res.js)| Medium|
3738
| 40|[Combination Sum II](https://leetcode.com/problems/combination-sum-ii/)|[JavaScript](./src/combination-sum-ii/res.js)| Medium|
3839
| 41|[First Missing Positive](https://leetcode.com/problems/first-missing-positive/description/)|[JavaScript](./src/first-missing-positive/res.js)| Hard|

‎src/count-and-say/res.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
functioncountAndSay(n:number):string{
2+
letresult='1';
3+
4+
for(leti=1;i<n;i++){
5+
letnewResult:string='';
6+
letstackList:string[]=result.split('');
7+
8+
letcurrentCount=1;
9+
letcurrentChar=stackList[0];
10+
for(letj=1;j<stackList.length;j++){
11+
if(currentChar===stackList[j]){
12+
currentCount++;
13+
}else{
14+
newResult+=`${currentCount}${currentChar}`;
15+
currentChar=stackList[j];
16+
currentCount=1;
17+
}
18+
}
19+
20+
if(currentCount){
21+
newResult+=`${currentCount}${currentChar}`;
22+
}
23+
24+
result=newResult;
25+
}
26+
27+
returnresult;
28+
};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp