Beats 76.64%🔥|| easy JAVA Solution✅
Intuition\nthe main idea of the problem is to try to make all value of the arry are Close and to try to fill 2 cup in each cycle \n# Approach\nStep 1 :\n    sor
# Intuition\nthe main idea of the problem is to try to make all value of the arry are Close and to try to fill 2 cup in each cycle \n# Approach\nStep 1 :\n    sorting the arry to get the biggiest and the medium and the smallest value\nStep 2 : \n    decrease the biggiest and the midium value \nStep 3 :\n    resortin the array by compare each value by other to make always the biggiest value at the firist posation and the midimu at the secend posation \n# Complexity\n- Time complexity:\nO(n)\n- Space complexity:\nO(1)\n# Code\n```\nclass Solution {\n    public int fillCups(int[] amount) {\n\n        Arrays.sort(amount);\n        int biggiestAmount = amount[2];\n        int midiumAmount = amount[1];\n        int smallestAmount = amount[0];\n        int minNumOfSec = 0;\n\n        while (biggiestAmount > 0) {\n\n            minNumOfSec++;\n            biggiestAmount--;\n            midiumAmount--;\n            if (biggiestAmount < midiumAmount) {\n                int temp = biggiestAmount;\n                biggiestAmount = midiumAmount;\n                midiumAmount = temp;\n            }\n            if (midiumAmount < smallestAmount) {\n\n                if (biggiestAmount < smallestAmount) {\n                    int temp = biggiestAmount;\n                    biggiestAmount = smallestAmount;\n                    smallestAmount = temp;\n                }\n\n                int temp = midiumAmount;\n                midiumAmount = smallestAmount;\n                smallestAmount = temp;\n            }\n        }\n\n        return minNumOfSec;\n    }\n}\n```
['Java']