Skip to content

Commit 75afaa1

Browse files
authored
Merge pull request #611 from fartem/2335_Minimum_Amount_of_Time_to_Fill_Cups
2024-04-25 v. 5.5.4: added "2335. Minimum Amount of Time to Fill Cups"
2 parents afba9fb + 4b39094 commit 75afaa1

4 files changed

+23
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,3 +414,4 @@ Profile on LeetCode: [fartem](https://leetcode.com/fartem/).
414414
| 2319. Check if Matrix Is X-Matrix | [Link](https://leetcode.com/problems/check-if-matrix-is-x-matrix/) | [Link](./lib/easy/2319_check_if_matrix_is_x_matrix.rb) |
415415
| 2325. Decode the Message | [Link](https://leetcode.com/problems/decode-the-message/) | [Link](./lib/easy/2325_decode_the_message.rb) |
416416
| 2331. Evaluate Boolean Binary Tree | [Link](https://leetcode.com/problems/evaluate-boolean-binary-tree/) | [Link](./lib/easy/2331_evaluate_boolean_binary_tree.rb) |
417+
| 2335. Minimum Amount of Time to Fill Cups | [Link](https://leetcode.com/problems/minimum-amount-of-time-to-fill-cups/) | [Link](./lib/easy/2335_minimum_amount_of_time_to_fill_cups.rb) |

leetcode-ruby.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ require 'English'
55
::Gem::Specification.new do |s|
66
s.required_ruby_version = '>= 3.0'
77
s.name = 'leetcode-ruby'
8-
s.version = '5.5.3'
8+
s.version = '5.5.4'
99
s.license = 'MIT'
1010
s.files = ::Dir['lib/**/*.rb'] + %w[bin/leetcode-ruby README.md LICENSE]
1111
s.executable = 'leetcode-ruby'
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# frozen_string_literal: true
2+
3+
# https://leetcode.com/problems/minimum-amount-of-time-to-fill-cups/
4+
# @param {Integer[]} amount
5+
# @return {Integer}
6+
def fill_cups(amount)
7+
[amount.max, (amount.sum + 1) / 2].max
8+
end
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# frozen_string_literal: true
2+
3+
require_relative '../test_helper'
4+
require_relative '../../lib/easy/2335_minimum_amount_of_time_to_fill_cups'
5+
require 'minitest/autorun'
6+
7+
class MinimumAmountOfTimeToFillCupsTest < ::Minitest::Test
8+
def test_default
9+
assert_equal(4, fill_cups([1, 4, 2]))
10+
assert_equal(7, fill_cups([5, 4, 4]))
11+
assert_equal(5, fill_cups([5, 0, 0]))
12+
end
13+
end

0 commit comments

Comments
 (0)