Skip to content

Commit 452d24e

Browse files
authored
resolve bug on golang solution 121
1 parent 32ac4a4 commit 452d24e

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

solution/0100-0199/0121.Best Time to Buy and Sell Stock/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,12 @@ public:
116116
117117
```go
118118
func maxProfit(prices []int) (ans int) {
119-
mi := prices[0]
119+
mi, ans := prices[0] ,0
120120
for _, v := range prices {
121121
ans = max(ans, v-mi)
122122
mi = min(mi, v)
123123
}
124-
return
124+
return ans
125125
}
126126
```
127127

solution/0100-0199/0121.Best Time to Buy and Sell Stock/README_EN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,12 @@ public:
114114
115115
```go
116116
func maxProfit(prices []int) (ans int) {
117-
mi := prices[0]
117+
mi, ans := prices[0] ,0
118118
for _, v := range prices {
119119
ans = max(ans, v-mi)
120120
mi = min(mi, v)
121121
}
122-
return
122+
return ans
123123
}
124124
```
125125

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
func maxProfit(prices []int) (ans int) {
2-
mi := prices[0]
2+
mi, ans := prices[0] ,0
33
for _, v := range prices {
44
ans = max(ans, v-mi)
55
mi = min(mi, v)
66
}
7-
return
7+
return ans
88
}

0 commit comments

Comments
 (0)