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

Commitb61dba0

Browse files
committed
add new files
1 parentaa0d535 commitb61dba0

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

‎713. Subarray Product Less Than K.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package main
2+
3+
/**
4+
滑动窗口
5+
*/
6+
7+
funcnumSubarrayProductLessThanK(nums []int,kint)int {
8+
ifk<=1 {
9+
return0
10+
}
11+
count,left,one:=0,0,1
12+
forright:=0;right<len(nums);right++ {
13+
one*=nums[right]
14+
forone>=k {
15+
one/=nums[left]
16+
left++
17+
}
18+
count+=right-left+1
19+
}
20+
returncount
21+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package main
2+
3+
funcmaxProfit(prices []int,feeint)int {
4+
cash,hold:=0,-prices[0]
5+
fori:=1;i<len(prices);i++ {
6+
cash=max(cash,hold+prices[i]-fee)
7+
hold=max(hold,cash-prices[i])
8+
}
9+
returncash
10+
}
11+
12+
funcmax(x,yint)int {
13+
ifx>y {
14+
returnx
15+
}
16+
returny
17+
}

‎868. Binary Gap.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ func binaryGap(N int) int {
77
return0
88
}
99

10-
for ;N>0;N>>=1 {
11-
ifN&1==1 {
10+
for ;N>0;N>>=1 {//N不断的右移
11+
ifN&1==1 {//判断是否等于1
1212
ifmax==0 {
1313
max=1
1414
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp