Warning: mkdir(): No space left on device in /var/www/tgoop/post.php on line 37

Warning: file_put_contents(aCache/aDaily/post/yeahub_go_backend/--): Failed to open stream: No such file or directory in /var/www/tgoop/post.php on line 50
Golang Backend | YeaHub@yeahub_go_backend P.185
YEAHUB_GO_BACKEND Telegram 185
#ЛитКод
Задача: 1518. Water Bottles

Есть numBottles бутылок , которые изначально наполнены водой. Вы можете обменять numExchange пустых бутылок на одну полную бутылку воды на рынке.

Операция питья полной бутылки воды превращает её в пустую бутылку.

Даны два целых числа numBottles и numExchange. Верните максимальное количество бутылок с водой, которые вы можете выпить.

Пример:
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.


👨‍💻 Алгоритм:

1️⃣ Инициализируйте переменную ответа consumedBottles значением 0.

2️⃣ Продолжайте выполнять следующие действия, пока количество numBottles больше или равно numExchange:
— Выпейте numExchange количество полных бутылок, т.е. добавьте numExchange к consumedBottles.
— Уменьшите numExchange от доступных полных бутылок numBottles.
— Обменяйте пустые бутылки на одну полную бутылку, т.е. увеличьте numBottles на одну.

3️⃣ Верните consumedBottles + numBottles.

😎 Решение🐍
func numWaterBottles(numBottles int, numExchange int) int {
consumedBottles := 0

for numBottles >= numExchange {
consumedBottles += numExchange
numBottles -= numExchange
numBottles++
}

return consumedBottles + numBottles
}


👉Новости 👉База вопросов
Please open Telegram to view this post
VIEW IN TELEGRAM
👍1



tgoop.com/yeahub_go_backend/185
Create:
Last Update:

#ЛитКод
Задача: 1518. Water Bottles

Есть numBottles бутылок , которые изначально наполнены водой. Вы можете обменять numExchange пустых бутылок на одну полную бутылку воды на рынке.

Операция питья полной бутылки воды превращает её в пустую бутылку.

Даны два целых числа numBottles и numExchange. Верните максимальное количество бутылок с водой, которые вы можете выпить.

Пример:

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.


👨‍💻 Алгоритм:

1️⃣ Инициализируйте переменную ответа consumedBottles значением 0.

2️⃣ Продолжайте выполнять следующие действия, пока количество numBottles больше или равно numExchange:
— Выпейте numExchange количество полных бутылок, т.е. добавьте numExchange к consumedBottles.
— Уменьшите numExchange от доступных полных бутылок numBottles.
— Обменяйте пустые бутылки на одну полную бутылку, т.е. увеличьте numBottles на одну.

3️⃣ Верните consumedBottles + numBottles.

😎 Решение🐍
func numWaterBottles(numBottles int, numExchange int) int {
consumedBottles := 0

for numBottles >= numExchange {
consumedBottles += numExchange
numBottles -= numExchange
numBottles++
}

return consumedBottles + numBottles
}


👉Новости 👉База вопросов

BY Golang Backend | YeaHub




Share with your friend now:
tgoop.com/yeahub_go_backend/185

View MORE
Open in Telegram


Telegram News

Date: |

The best encrypted messaging apps Private channels are only accessible to subscribers and don’t appear in public searches. To join a private channel, you need to receive a link from the owner (administrator). A private channel is an excellent solution for companies and teams. You can also use this type of channel to write down personal notes, reflections, etc. By the way, you can make your private channel public at any moment. Ng was convicted in April for conspiracy to incite a riot, public nuisance, arson, criminal damage, manufacturing of explosives, administering poison and wounding with intent to do grievous bodily harm between October 2019 and June 2020. On Tuesday, some local media outlets included Sing Tao Daily cited sources as saying the Hong Kong government was considering restricting access to Telegram. Privacy Commissioner for Personal Data Ada Chung told to the Legislative Council on Monday that government officials, police and lawmakers remain the targets of “doxxing” despite a privacy law amendment last year that criminalised the malicious disclosure of personal information. So far, more than a dozen different members have contributed to the group, posting voice notes of themselves screaming, yelling, groaning, and wailing in various pitches and rhythms.
from us


Telegram Golang Backend | YeaHub
FROM American