Easy Recursion | | C++
We have two type of moves \n\t1. fill 2 different cups \n\t2. fill 1 cup\nObservation .. \n\talways decrement from 2 maximum cups\n\twhen 2 cups become ZERO, em
We have two type of moves \n\t1. fill 2 different cups \n\t2. fill 1 cup\nObservation .. \n\talways decrement from 2 maximum cups\n\twhen 2 cups become ZERO, empty the last cup in single move\n\n```\nclass Solution {  \nprivate:\n    // counter for Steps\n    int count = 0;\n    void check(vector<int>& a){\n        // sort the array \n        sort(a.begin(), a.end());\n        // base case // if all elements are ZERO\n        if (a[0] + a[1] + a[2] == 0)  return;\n        // decrement from last to element\n        if (a[1] and a[2]){\n            a[1]--, a[2]--;\n            count++;\n        }\n        else{\n            // at this point only last element is non zero // so we can directly make it zero\n            count += a[2];\n            a[2] = 0;\n        }\n        // recursive call \n        check(a);\n    }\npublic:\n    int fillCups(vector<int>& a) {\n        check(a);\n        return count;\n    }\n};\n```\n
['C']