leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

commit ded12460e5feb035fb1d1feeae71ee4615f3c84c
parent 1feacef4beff8fd01d3e03853000fd03831d930e
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Wed,  6 Dec 2023 19:52:08 +0000

Daily Problem

Diffstat:
AProblems/1716.cpp | 13+++++++++++++
MREADME.md | 1+
2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/Problems/1716.cpp b/Problems/1716.cpp @@ -0,0 +1,13 @@ +class Solution { + public: + int totalMoney(int n) { + const int whole = n / 7, rest = n % 7; + int res = whole * (7 * whole + 49) / 2; + + for (int i = 1; i <= rest; i++) { + res += whole + i; + } + + return res; + } +}; diff --git a/README.md b/README.md @@ -745,6 +745,7 @@ for solving problems. | 1701 | Medium | [Average Waiting Time](Problems/1701.cpp) | | 1704 | Easy | [Determine if String Halves Are Alike](Problems/1704.cpp) | | 1706 | Medium | [Where Will the Ball Fall](Problems/1706.cpp) | +| 1716 | Easy | [Calculate Money in Leetcode Bank](Problems/1716.cpp) | | 1721 | Medium | [Swapping Nodes in a Linked List](Problems/1721.cpp) | | 1722 | Medium | [Minimize Hamming Distance After Swap Operations](Problems/1722.cpp) | | 1726 | Medium | [Tuple with Same Product](Problems/1726.cpp) |