<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      [LeetCode] 1518. Water Bottles

      There are numBottles water bottles that are initially full of water. You can exchange numExchange empty water bottles from the market with one full water bottle.

      The operation of drinking a full water bottle turns it into an empty bottle.

      Given the two integers numBottles and numExchange, return the maximum number of water bottles you can drink.

      Example 1:
      Example 1
      Input: numBottles = 9, numExchange = 3
      Output: 13
      Explanation: You can exchange 3 empty bottles to get 1 full water bottle.
      Number of water bottles you can drink: 9 + 3 + 1 = 13.

      Example 2:
      Example 2
      Input: numBottles = 15, numExchange = 4
      Output: 19
      Explanation: You can exchange 4 empty bottles to get 1 full water bottle.
      Number of water bottles you can drink: 15 + 3 + 1 = 19.

      Constraints:
      1 <= numBottles <= 100
      2 <= numExchange <= 100

      換水問題。

      超市正在促銷,你可以用 numExchange 個空水瓶從超市兌換一瓶水。最開始,你一共購入了 numBottles 瓶水。

      如果喝掉了水瓶中的水,那么水瓶就會變成空的。

      給你兩個整數(shù) numBottles 和 numExchange ,返回你 最多 可以喝到多少瓶水。

      思路

      這是一道模擬題。題目說了每 numExchange 個空瓶可以換一瓶水,那么我們可以模擬這個過程,每喝掉 numExchange 瓶水,就去兌換一瓶水,直到 numBottles 喝光。注意兌換的水要加回 numBottles。

      復(fù)雜度

      時間O(n)
      空間O(1)

      代碼

      Java實現(xiàn)

      class Solution {
          public int numWaterBottles(int numBottles, int numExchange) {
              int count = 0;
              while (numBottles >= numExchange) {
                  count += numExchange;
                  numBottles -= numExchange - 1;
              }
              return count + numBottles;
          }
      }
      
      posted @ 2025-10-01 07:58  CNoodle  閱讀(22)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 国产精品国产三级国av| 999精品色在线播放| 视频一区二区不中文字幕| 国产成人精品白浆免费视频试看| 铅山县| 自拍偷自拍亚洲一区二区| 婷婷色香五月综合缴缴情香蕉 | 内射视频福利在线观看| 久久一夜天堂av一区二区| 丝袜国产一区av在线观看| 亚洲欧美综合人成在线| 亚洲 欧美 唯美 国产 伦 综合| 18禁网站免费无遮挡无码中文| 六盘水市| 黑人av无码一区| 午夜大片免费男女爽爽影院| 免费无遮挡无码永久视频| 狠狠躁夜夜人人爽天96| 欧美极品色午夜在线视频| 不卡av电影在线| 亚洲制服无码一区二区三区| 亚洲无av在线中文字幕| 国产日产免费高清欧美一区| 少妇爽到呻吟的视频| 亚洲一区二区三区自拍麻豆| 夜夜添无码试看一区二区三区| 亚洲精品日本久久久中文字幕| 国产精品一区二区三粉嫩| 国产18禁黄网站禁片免费视频| 亚洲免费视频一区二区三区| 99久久成人亚洲精品观看| 日本视频一两二两三区| 欧美成人h精品网站| 国产成人免费永久在线平台| 久久精品国产亚洲AⅤ无码| 免费看视频的网站| 久久精品人妻少妇一区二| 欧美一区二区三区成人久久片| 成人国产精品日本在线观看| 中文字幕精品亚洲字幕成| 国产自在自线午夜精品 |