Update 1518 solution

This commit is contained in:
halfrost
2021-12-21 21:21:21 +08:00
parent c99d3ef68f
commit 577d3d465f
5 changed files with 86 additions and 5 deletions

View File

@ -1,4 +1,4 @@
# [1518. Water Bottles](https://leetcode-cn.com/problems/water-bottles/)
# [1518. Water Bottles](https://leetcode.com/problems/water-bottles/)
## 题目
@ -51,8 +51,7 @@ Return the maximum number of water bottles you can drink.
## 解题思路
- 模拟
首先我们一定可以喝到 numBottles 瓶酒,剩下 numBottles 个空瓶。接下来我们可以拿空瓶子换酒,每次拿出 numExchange 个瓶子换一瓶酒然后再喝完这瓶酒得到一个空瓶。这样模拟下去直到所有的空瓶子小于numExchange结束
- 模拟。首先我们一定可以喝到 numBottles 瓶酒,剩下 numBottles 个空瓶。接下来我们可以拿空瓶子换酒,每次拿出 numExchange 个瓶子换一瓶酒然后再喝完这瓶酒得到一个空瓶。这样模拟下去直到所有的空瓶子小于numExchange结束。
## 代码