Skip to content

Commit eb240b3

Browse files
add 2739
1 parent 25919d9 commit eb240b3

File tree

3 files changed

+44
-0
lines changed
  • paginated_contents/algorithms/3rd_thousand
  • src

3 files changed

+44
-0
lines changed

Diff for: paginated_contents/algorithms/3rd_thousand/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
| 2751 | [Robot Collisions](https://leetcode.com/problems/robot-collisions/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2751.java) | | Hard | Stack, Simulation
1616
| 2748 | [Number of Beautiful Pairs](https://leetcode.com/problems/number-of-beautiful-pairs/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2748.java) | | Easy |
1717
| 2744 | [Find Maximum Number of String Pairs](https://leetcode.com/problems/find-maximum-number-of-string-pairs/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2744.java) | | Easy |
18+
| 2739 | [Total Distance Traveled](https://leetcode.com/problems/total-distance-traveled/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2739.java) | | Easy |
1819
| 2716 | [Minimize String Length](https://leetcode.com/problems/minimize-string-length/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2716.java) | [:tv:](https://youtu.be/aMJ3T0K8LjI) | Easy |
1920
| 2710 | [Remove Trailing Zeros From a String](https://leetcode.com/problems/remove-trailing-zeros-from-a-string/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2710.java) | | Easy |
2021
| 2706 | [Buy Two Chocolates](https://leetcode.com/problems/buy-two-chocolates/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2706.java) | | Easy |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.fishercoder.solutions.thirdthousand;
2+
3+
public class _2739 {
4+
public static class Solution1 {
5+
public int distanceTraveled(int mainTank, int additionalTank) {
6+
int distance = 0;
7+
while (mainTank >= 5) {
8+
distance += 5 * 10;
9+
mainTank -= 5;
10+
if (additionalTank > 0) {
11+
mainTank++;
12+
additionalTank--;
13+
}
14+
}
15+
if (mainTank > 0) {
16+
distance += 10 * mainTank;
17+
}
18+
return distance;
19+
}
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.fishercoder.thirdthousand;
2+
3+
import com.fishercoder.solutions.thirdthousand._2739;
4+
import org.junit.jupiter.api.BeforeEach;
5+
import org.junit.jupiter.api.Test;
6+
7+
import static org.junit.jupiter.api.Assertions.assertEquals;
8+
9+
public class _2739Test {
10+
private static _2739.Solution1 solution1;
11+
12+
@BeforeEach
13+
public void setup() {
14+
solution1 = new _2739.Solution1();
15+
}
16+
17+
@Test
18+
public void test1() {
19+
assertEquals(20, solution1.distanceTraveled(2, 1));
20+
}
21+
22+
}

0 commit comments

Comments
 (0)