Java Solution- Easy To Understand
\nclass Solution {\n    public int fillCups(int[] amount) {\n        int seconds = 0;\n        Arrays.sort(amount);//First sorting the array.\n        int highe
```\nclass Solution {\n    public int fillCups(int[] amount) {\n        int seconds = 0;\n        Arrays.sort(amount);//First sorting the array.\n        int highestNum = amount.length-1;\n        int secondHighestNum = amount.length-2;\n        //Now taking the two biggest numbers of the array which will be at the last and the second last index as the array is sorted.\n        while (amount[highestNum]>0 && amount[secondHighestNum]>0){\n            //If both these numbers are greater than 0 then we can fill two cups in one second and then decreasing their values.\n            amount[highestNum]--;\n            amount[secondHighestNum]--;\n            seconds++;//This is one ans\n            Arrays.sort(amount);//Now, again sorting using the inbuilt sort of java class so that the biggest two numbers are at the last two index of the array\n        }\n\n        //The above loop will break when either of the two places becomes 0\n        //If the number at last and secon last index were equal, then both of them will become zero\n        //Or if it is not the case, then only one type of water is present in the dispenser\n        while (amount[highestNum]>0){\n            //So, decreasing it one by one till it becomes zero\n            amount[highestNum]--;\n            seconds++;\n        }\n        return seconds;//Hence, we have found our answer\n    }\n}\n```\nComment if there is any doubt.\nIf you liked the solution or found it easy to understand, do upvote :)\nThankyou!!
['Array', 'Sorting', 'Java']