Skip to content

Commit 187a7fb

Browse files
solves #2335: Minimum Amount of Time to Fill Cups in java
1 parent 36b6ee6 commit 187a7fb

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@
749749
| 2319 | [Check if Matrix Is X-Matrix](https://leetcode.com/problems/check-if-matrix-is-x-matrix) | [![Java](assets/java.png)](src/CountAsterisks.java) | |
750750
| 2325 | [Decode the Message](https://leetcode.com/problems/decode-the-message) | [![Java](assets/java.png)](src/DecodeTheMessage.java) | |
751751
| 2331 | [Evaluate Boolean Binary Tree](https://leetcode.com/problems/evaluate-boolean-binary-tree) | [![Java](assets/java.png)](src/EvaluateBooleanBinaryTree.java) | |
752-
| 2335 | [Minimum Amount of Time to Fill Cups](https://leetcode.com/problems/minimum-amount-of-time-to-fill-cups) | | |
752+
| 2335 | [Minimum Amount of Time to Fill Cups](https://leetcode.com/problems/minimum-amount-of-time-to-fill-cups) | [![Java](assets/java.png)](src/MinimumAmountOfTimeToFillCups.java) | |
753753
| 2439 | [Minimize Maximum of Array](https://leetcode.com/problems/minimize-maximum-of-array) | [![Python](assets/python.png)](python/minimize_maximum_of_array.py) | |
754754
| 2341 | [Maximum Number of Pairs in Array](https://leetcode.com/problems/maximum-number-of-pairs-in-array) | | |
755755
| 2347 | [Best Poker Hand](https://leetcode.com/problems/best-poker-hand) | | |

Diff for: src/MinimumAmountOfTimeToFillCups.java

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// https://leetcode.com/problems/minimum-amount-of-time-to-fill-cups
2+
// T: O(1)
3+
// S: O(1)
4+
5+
import java.util.Arrays;
6+
7+
public class MinimumAmountOfTimeToFillCups {
8+
public int fillCups(int[] amount) {
9+
return Math.max(
10+
Arrays.stream(amount).max().getAsInt(),
11+
(Arrays.stream(amount).sum() + 1) / 2
12+
);
13+
}
14+
}

0 commit comments

Comments
 (0)