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

Commitca22e0f

Browse files
authored
Improved tasks
1 parentf5e5230 commitca22e0f

File tree

37 files changed

+106
-85
lines changed

37 files changed

+106
-85
lines changed

‎src/main/ts/g0001_0100/s0002_add_two_numbers/solution.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import{ListNode}from'../../com_github_leetcode/listnode'
77

8-
/*
8+
/**
99
* Definition for singly-linked list.
1010
* class ListNode {
1111
* val: number

‎src/main/ts/g0001_0100/s0023_merge_k_sorted_lists/solution.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import{ListNode}from'../../com_github_leetcode/listnode'
66

7-
/*
7+
/**
88
* Definition for singly-linked list.
99
* class ListNode {
1010
* val: number

‎src/main/ts/g0001_0100/s0030_substring_with_concatenation_of_all_words/solution.ts‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,26 @@ function findSubstring(s: string, words: string[]): number[] {
66
letn1=words[0].length
77
letn2=s.length
88
letmap1=newMap<string,number>()
9-
109
for(letchofwords){
1110
map1.set(ch,(map1.get(ch)??0)+1)
1211
}
13-
1412
for(leti=0;i<n1;i++){
1513
letleft=i
1614
letj=i
1715
letc=0
1816
letmap2=newMap<string,number>()
19-
2017
while(j+n1<=n2){
2118
letword1=s.substring(j,j+n1)
2219
j+=n1
23-
2420
if(map1.has(word1)){
2521
map2.set(word1,(map2.get(word1)??0)+1)
2622
c++
27-
2823
while((map2.get(word1)??0)>(map1.get(word1)??0)){
2924
letword2=s.substring(left,left+n1)
3025
map2.set(word2,(map2.get(word2)??0)-1)
3126
left+=n1
3227
c--
3328
}
34-
3529
if(c===words.length){
3630
ans.push(left)
3731
}

‎src/main/ts/g0001_0100/s0031_next_permutation/solution.ts‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66
*/
77
functionnextPermutation(nums:number[]):void{
88
letswapperIndex:number|null=null
9-
109
for(letind=nums.length-1;ind>=0&&swapperIndex==null;ind--){
1110
if(nums[ind]>nums[ind-1]){
1211
swapperIndex=ind-1
1312
}
1413
}
15-
16-
if(swapperIndex==null)nums.sort((a,b)=>a-b)
17-
else{
14+
if(swapperIndex==null){
15+
nums.sort((a,b)=>a-b)
16+
}else{
1817
nums.splice(swapperIndex+1,nums.length, ...nums.slice(swapperIndex+1,nums.length).sort((a,b)=>a-b))
1918
letindToBringForward=swapperIndex+1
2019
while(nums[indToBringForward]<=nums[swapperIndex])++indToBringForward

‎src/main/ts/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/solution.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ function searchRange(nums: number[], target: number): number[] { //NOSONAR
99
letleft2=left1
1010
letright1=nums.length-1
1111
letright2=right1
12-
1312
while(left1<=right1||left2<=right2){
1413
if(left1<=right1){
1514
letmid1=Math.floor((left1+right1)/2)
@@ -22,7 +21,6 @@ function searchRange(nums: number[], target: number): number[] { //NOSONAR
2221
right1=mid1-1
2322
}
2423
}
25-
2624
if(left2<=right2){
2725
letmid2=Math.floor((left2+right2)/2)
2826
if(nums[mid2]==target){

‎src/main/ts/g0001_0100/s0036_valid_sudoku/solution.ts‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,16 @@ function isValidSudoku(board: string[][]): boolean {
55
letrowSet:number[]=newArray(9).fill(0)
66
letcolSet:number[]=newArray(9).fill(0)
77
letboxSet:number[]=newArray(9).fill(0)
8-
98
for(leti=0;i<9;i++){
109
for(letj=0;j<9;j++){
1110
if(board[i][j]==='.'){
1211
continue
1312
}
1413
letval=board[i][j].charCodeAt(0)-'0'.charCodeAt(0)
1514
letboxIndex=Math.floor(i/3)*3+Math.floor(j/3)
16-
1715
if(rowSet[i]&(1<<val)||colSet[j]&(1<<val)||boxSet[boxIndex]&(1<<val)){
1816
returnfalse
1917
}
20-
2118
rowSet[i]|=1<<val
2219
colSet[j]|=1<<val
2320
boxSet[boxIndex]|=1<<val

‎src/main/ts/g0001_0100/s0039_combination_sum/solution.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
functioncombinationSum(candidates:number[],target:number):number[][]{
77
constresult:number[][]=[]
88
constpath:number[]=[]
9-
109
constcomFunct=(index:number,sum:number)=>{
1110
if(sum===target){
1211
result.push([...path])

‎src/main/ts/g0001_0100/s0054_spiral_matrix/solution.ts‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,24 @@ function spiralOrder(matrix: number[][]): number[] {
88
c=0
99
letbigR=matrix.length-1
1010
letbigC=matrix[0].length-1
11-
1211
while(r<=bigR&&c<=bigC){
1312
for(leti=c;i<=bigC;i++){
1413
result.push(matrix[r][i])
1514
}
1615
r++
17-
1816
for(leti=r;i<=bigR;i++){
1917
result.push(matrix[i][bigC])
2018
}
2119
bigC--
22-
2320
for(leti=bigC;i>=c&&r<=bigR;i--){
2421
result.push(matrix[bigR][i])
2522
}
2623
bigR--
27-
2824
for(leti=bigR;i>=r&&c<=bigC;i--){
2925
result.push(matrix[i][c])
3026
}
3127
c++
3228
}
33-
3429
returnresult
3530
}
3631

‎src/main/ts/g0001_0100/s0070_climbing_stairs/solution.ts‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@
44
// #Big_O_Time_O(n)_Space_O(n) #2025_03_23_Time_0_ms_(100.00%)_Space_56.23_MB_(5.15%)
55

66
functionclimbStairs(n:number,memo:Record<string,number>={}):number{
7-
if(ninmemo)returnmemo[n]
8-
if(n===0)return1
9-
if(n<0)return0
7+
if(ninmemo){
8+
returnmemo[n]
9+
}
10+
if(n===0){
11+
return1
12+
}
13+
if(n<0){
14+
return0
15+
}
1016
memo[n]=climbStairs(n-1,memo)+climbStairs(n-2,memo)
1117
returnmemo[n]
1218
}

‎src/main/ts/g0001_0100/s0072_edit_distance/solution.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ function minDistance(word1: string, word2: string): number {
88
constl1=word1.length
99
constl2=word2.length
1010
constdfs=(w1:number,w2:number):number=>{
11-
if(memo[w1][w2]!=undefined)returnmemo[w1][w2]
11+
if(memo[w1][w2]!=undefined){
12+
returnmemo[w1][w2]
13+
}
1214
if(w1==l1&&w2==l2){
1315
memo[w1][w2]=0
1416
return0

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp