C++ recursion
Code\n\nclass Solution {\npublic:\n    int solve(vector<int> &nums, int idx, int prev, int count)\n    {\n        // base case\n        if(count == 3)\n        
# Code\n```\nclass Solution {\npublic:\n    int solve(vector<int> &nums, int idx, int prev, int count)\n    {\n        // base case\n        if(count == 3)\n            return 0;\n        if(idx >= nums.size())\n            return INT_MAX;\n        \n        int incl = INT_MAX;\n        // if no number was taken in the sum previously\n        if(count == 0)\n        {\n            incl = solve(nums, idx+1, idx, count+1);\n        }   \n        // if 1 number has been already added to the sum\n        else if(count == 1)\n        {\n            if(nums[idx] > nums[prev])\n                incl = solve(nums, idx+1, idx, count+1);\n        }\n        // if 2 number have been already added to the sum\n        else if(count == 2)\n        {\n            if(nums[idx] < nums[prev])\n                incl = solve(nums, idx+1, idx, count+1);\n        }\n        \n        // if able to find 3 numbers the add the current number to the sum\n        if(incl != INT_MAX)\n            incl += nums[idx];\n        \n        // exclude current number\n        int excl = solve(nums, idx+1, prev, count);\n        \n        return min(incl, excl);\n    }\n    \n    int minimumSum(vector<int>& nums) \n    {\n        int ans = solve(nums, 0, -1, 0);\n        \n        return (ans == INT_MAX)?-1: ans;\n    }\n};\n```
['Recursion', 'C++']