Skip to content

Latest commit

 

History

History

minimum-amount-of-time-to-fill-cups

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Minimum amount of time to fill cups

Problem link

Solutions

Solution.cpp

// https://leetcode.com/problems/minimum-amount-of-time-to-fill-cups

class Solution {
 public:
  int fillCups(vector<int>& amount) {
    int ret = 0;
    while (1) {
      sort(amount.begin(), amount.end());
      if (!amount.back()) break;
      ++ret;
      --amount[2];
      if (amount[1]) --amount[1];
    }
    return ret;
  }
};

Tags