Skip to content

Commit 465f54f

Browse files
authored
Merge pull request #168 from fartem/calculate-money-in-leetcode-bank
2023-01-20 update: added "1716. Calculate Money in Leetcode Bank"
2 parents ce62f88 + b74ed1a commit 465f54f

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ Profile on LeetCode: [fartem](https://leetcode.com/fartem/).
299299
| 1700. Number of Students Unable to Eat Lunch | [Link](https://leetcode.com/problems/number-of-students-unable-to-eat-lunch/) | [Link](./src/main/java/com/smlnskgmail/jaman/leetcodejava/easy/NumberOfStudentsUnableToEatLunch.java) |
300300
| 1704. Determine if String Halves Are Alike | [Link](https://leetcode.com/problems/determine-if-string-halves-are-alike/) | [Link](./src/main/java/com/smlnskgmail/jaman/leetcodejava/easy/DetermineIfStringHalvesAreAlike.java) |
301301
| 1710. Maximum Units on a Truck | [Link](https://leetcode.com/problems/maximum-units-on-a-truck/) | [Link](./src/main/java/com/smlnskgmail/jaman/leetcodejava/easy/MaximumUnitsOnATruck.java) |
302+
| 1716. Calculate Money in Leetcode Bank | [Link](https://leetcode.com/problems/calculate-money-in-leetcode-bank/) | [Link](./src/main/java/com/smlnskgmail/jaman/leetcodejava/easy/CalculateMoneyInLeetcodeBank.java) |
302303
| 1720. Decode XORed Array | [Link](https://leetcode.com/problems/decode-xored-array/) | [Link](./src/main/java/com/smlnskgmail/jaman/leetcodejava/easy/DecodeXORedArray.java) |
303304
| 1725. Number Of Rectangles That Can Form The Largest Square | [Link](https://leetcode.com/problems/number-of-rectangles-that-can-form-the-largest-square/) | [Link](./src/main/java/com/smlnskgmail/jaman/leetcodejava/easy/NumberOfRectanglesThatCanFormTheLargestSquare.java) |
304305
| 1732. Find the Highest Altitude | [Link](https://leetcode.com/problems/find-the-highest-altitude/) | [Link](./src/main/java/com/smlnskgmail/jaman/leetcodejava/easy/FindTheHighestAltitude.java) |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.smlnskgmail.jaman.leetcodejava.easy;
2+
3+
// https://leetcode.com/problems/calculate-money-in-leetcode-bank//
4+
public class CalculateMoneyInLeetcodeBank {
5+
6+
private final int input;
7+
8+
public CalculateMoneyInLeetcodeBank(int input) {
9+
this.input = input;
10+
}
11+
12+
public int solution() {
13+
int weeks = input / 7;
14+
int result = 0;
15+
for (int i = 1; i <= weeks; i++) {
16+
result += 7 * (i + 3);
17+
}
18+
for (int i = 7 * weeks; i < input; i++) {
19+
result += ++weeks;
20+
}
21+
return result;
22+
}
23+
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.smlnskgmail.jaman.leetcodejava.easy;
2+
3+
import org.junit.Test;
4+
5+
import static org.junit.Assert.assertEquals;
6+
7+
public class CalculateMoneyInLeetcodeBankTest {
8+
9+
@Test
10+
public void defaultTests() {
11+
assertEquals(10, new CalculateMoneyInLeetcodeBank(4).solution());
12+
assertEquals(37, new CalculateMoneyInLeetcodeBank(10).solution());
13+
assertEquals(96, new CalculateMoneyInLeetcodeBank(20).solution());
14+
}
15+
16+
}

0 commit comments

Comments
 (0)