java.lang.Object
g2301_2400.s2335_minimum_amount_of_time_to_fill_cups.Solution

public class Solution extends Object
2335 - Minimum Amount of Time to Fill Cups.<p>Easy</p> <p>You have a water dispenser that can dispense cold, warm, and hot water. Every second, you can either fill up <code>2</code> cups with <strong>different</strong> types of water, or <code>1</code> cup of any type of water.</p> <p>You are given a <strong>0-indexed</strong> integer array <code>amount</code> of length <code>3</code> where <code>amount[0]</code>, <code>amount[1]</code>, and <code>amount[2]</code> denote the number of cold, warm, and hot water cups you need to fill respectively. Return <em>the <strong>minimum</strong> number of seconds needed to fill up all the cups</em>.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> amount = [1,4,2]</p> <p><strong>Output:</strong> 4</p> <p><strong>Explanation:</strong> One way to fill up the cups is:</p> <p>Second 1: Fill up a cold cup and a warm cup.</p> <p>Second 2: Fill up a warm cup and a hot cup.</p> <p>Second 3: Fill up a warm cup and a hot cup.</p> <p>Second 4: Fill up a warm cup.</p> <p>It can be proven that 4 is the minimum number of seconds needed.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> amount = [5,4,4]</p> <p><strong>Output:</strong> 7</p> <p><strong>Explanation:</strong> One way to fill up the cups is:</p> <p>Second 1: Fill up a cold cup, and a hot cup.</p> <p>Second 2: Fill up a cold cup, and a warm cup.</p> <p>Second 3: Fill up a cold cup, and a warm cup.</p> <p>Second 4: Fill up a warm cup, and a hot cup.</p> <p>Second 5: Fill up a cold cup, and a hot cup.</p> <p>Second 6: Fill up a cold cup, and a warm cup.</p> <p>Second 7: Fill up a hot cup.</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> amount = [5,0,0]</p> <p><strong>Output:</strong> 5</p> <p><strong>Explanation:</strong> Every second, we fill up a cold cup.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>amount.length == 3</code></li> <li><code>0 <= amount[i] <= 100</code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • fillCups

      public int fillCups(int[] amount)