8000 add 2706 · shaovoon/Leetcode@2ffda7d · GitHub
[go: up one dir, main page]

Skip to content
Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2ffda7d

Browse files
add 2706
1 parent 07c2938 commit 2ffda7d

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ _If you like this project, please leave me a star._ ★
99
| # | Title | Solutions | Video | Difficulty | Tag
1010
|------|----------------|------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------|----------------------------------|-------------
1111
| 2710 |[Remove Trailing Zeros From a String](https://leetcode.com/problems/remove-trailing-zeros-from-a-string/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2710.java) | | Easy |
12+
| 2706 |[Buy Two Chocolates](https://leetcode.com/problems/buy-two-chocolates/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2706.java) | | Easy |
1213
| 2696 |[Minimum String Length After Removing Substrings](https://leetcode.com/problems/minimum-string-length-after-removing-substrings/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2696.java) | | Easy |
1314
| 2670 |[Find the Distinct Difference Array](https://leetcode.com/problems/find-the-distinct-difference-array/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2670.java) | | Easy |
1415
| 2596 |[Check Knight Tour Configuration](https://leetcode.com/problems/check-knight-tour-configuration/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2596.java) | [:tv:](https://youtu.be/OBht8NT_09c) | Medium |
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.fishercoder.solutions;
2+
3+
import java.util.Arrays;
4+
5+
public class _2706 {
6+
public static class Solution1 {
7+
public int buyChoco(int[] prices, int money) {
8+
Arrays.sort(prices);
9+
if (prices[0] + prices[1] > money) {
10+
return money;
11+
} else {
12+
return money - prices[0] - prices[1];
13+
}
14+
}
15+
}
16+
}

0 commit comments

Comments
 (0)
0