From 2f3f35c5727cb9469e3c186f26217d8cb053e242 Mon Sep 17 00:00:00 2001
From: Steve2020 <841532108@qq.com>
Date: Fri, 8 Apr 2022 21:33:51 +0800
Subject: [PATCH 1/5] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=EF=BC=880860.=E6=9F=A0?=
=?UTF-8?q?=E6=AA=AC=E6=B0=B4=E6=89=BE=E9=9B=B6.md=EF=BC=89=EF=BC=9A?=
=?UTF-8?q?=E5=A2=9E=E5=8A=A0typescript=E7=89=88=E6=9C=AC?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
problems/0860.柠檬水找零.md | 34 ++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/problems/0860.柠檬水找零.md b/problems/0860.柠檬水找零.md
index f48ecf4d..026c2e63 100644
--- a/problems/0860.柠檬水找零.md
+++ b/problems/0860.柠檬水找零.md
@@ -254,5 +254,39 @@ var lemonadeChange = function(bills) {
```
+### TypeScript
+
+```typescript
+function lemonadeChange(bills: number[]): boolean {
+ let five: number = 0,
+ ten: number = 0;
+ for (let bill of bills) {
+ switch (bill) {
+ case 5:
+ five++;
+ break;
+ case 10:
+ if (five < 1) return false;
+ five--;
+ ten++
+ break;
+ case 20:
+ if (ten > 0 && five > 0) {
+ five--;
+ ten--;
+ } else if (five > 2) {
+ five -= 3;
+ } else {
+ return false;
+ }
+ break;
+ }
+ }
+ return true;
+};
+```
+
+
+
-----------------------
From 0e1cbda7153b3b5b2892110696f10afe7833a38f Mon Sep 17 00:00:00 2001
From: "Neil.Liu" <88214924@qq.com>
Date: Fri, 8 Apr 2022 23:56:49 +0800
Subject: [PATCH 2/5] =?UTF-8?q?Update=200121.=E5=8D=96=E8=82=A1=E7=A5=A8?=
=?UTF-8?q?=E7=9A=84=E6=9C=80=E4=BD=B3=E6=97=B6=E6=9C=BA.md=20=E8=B4=AA?=
=?UTF-8?q?=E5=BF=83=E4=BB=A5=E5=8F=8A=E5=8A=A8=E6=80=81=E8=A7=84=E5=88=92?=
=?UTF-8?q?=20Go=E7=89=88=E6=9C=AC?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
problems/0121.买卖股票的最佳时机.md | 52 ++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/problems/0121.买卖股票的最佳时机.md b/problems/0121.买卖股票的最佳时机.md
index e7c0ac65..f0bc3b97 100644
--- a/problems/0121.买卖股票的最佳时机.md
+++ b/problems/0121.买卖股票的最佳时机.md
@@ -311,7 +311,36 @@ class Solution:
```
Go:
+> 贪心法:
+```Go
+func maxProfit(prices []int) int {
+ low := math.MaxInt32
+ rlt := 0
+ for i := range prices{
+ low = min(low, prices[i])
+ rlt = max(rlt, prices[i]-low)
+ }
+ return rlt
+}
+func min(a, b int) int {
+ if a < b{
+ return a
+ }
+
+ return b
+}
+
+func max(a, b int) int {
+ if a > b{
+ return a
+ }
+
+ return b
+}
+```
+
+> 动态规划:版本一
```Go
func maxProfit(prices []int) int {
length:=len(prices)
@@ -338,6 +367,29 @@ func max(a,b int)int {
}
```
+> 动态规划:版本二
+```Go
+func maxProfit(prices []int) int {
+ dp := [2][2]int{}
+ dp[0][0] = -prices[0]
+ dp[0][1] = 0
+ for i := 1; i < len(prices); i++{
+ dp[i%2][0] = max(dp[(i-1)%2][0], -prices[i])
+ dp[i%2][1] = max(dp[(i-1)%2][1], dp[(i-1)%2][0]+prices[i])
+ }
+
+ return dp[(len(prices)-1)%2][1]
+}
+
+func max(a, b int) int {
+ if a > b{
+ return a
+ }
+
+ return b
+}
+```
+
JavaScript:
> 动态规划
From 2e18054079ecfa1147bfc4335fd6c62609a44c37 Mon Sep 17 00:00:00 2001
From: jonathanx111 <57882619+jonathanx111@users.noreply.github.com>
Date: Sat, 9 Apr 2022 13:49:55 -0400
Subject: [PATCH 3/5] =?UTF-8?q?=E7=BA=A0=E6=AD=A30027=E7=9A=84Swift?=
=?UTF-8?q?=E7=AD=94=E6=A1=88?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Swift答案写错了。改成对的答案。
---
problems/0027.移除元素.md | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/problems/0027.移除元素.md b/problems/0027.移除元素.md
index 8d6ca502..590cf0b9 100644
--- a/problems/0027.移除元素.md
+++ b/problems/0027.移除元素.md
@@ -281,10 +281,8 @@ func removeElement(_ nums: inout [Int], _ val: Int) -> Int {
for fastIndex in 0..
Date: Wed, 4 May 2022 18:06:13 +0800
Subject: [PATCH 4/5] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=B5=84=E6=BA=90?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 1d7f219d..501c5ed4 100644
--- a/README.md
+++ b/README.md
@@ -543,6 +543,7 @@
**来看看就知道了,你会发现相见恨晚!**
-
-
+
+
+
From aacbbfbd02613a7110e913fa00298ef0734107ac Mon Sep 17 00:00:00 2001
From: programmercarl <826123027@qq.com>
Date: Wed, 4 May 2022 18:11:46 +0800
Subject: [PATCH 5/5] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=B5=84=E6=BA=90?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 501c5ed4..38418322 100644
--- a/README.md
+++ b/README.md
@@ -531,7 +531,8 @@
如果是已工作,备注:姓名-城市-岗位-组队刷题。如果学生,备注:姓名-学校-年级-组队刷题。**备注没有自我介绍不通过哦**
-
+
+
@@ -545,5 +546,5 @@
-
+