Easy C++ Solution | Trial & Error Method
\nclass Solution {\npublic:\n    bool judgePoint24(vector<int>& cards) {\n         return solve(vector<double>(cards.begin(),cards.end()));\n    }\n    vector<d
```\nclass Solution {\npublic:\n    bool judgePoint24(vector<int>& cards) {\n         return solve(vector<double>(cards.begin(),cards.end()));\n    }\n    vector<double> solveType(double x,double y) {\n          return {x + y,x - y,x * y,y - x, x / y , y / x};\n    }\n    bool solve(vector<double> a) {\n         if(a.size() == 1) return abs(a[0] - 24) < 0.0001; // if a is reduced to 1 size then just check\n         for(int i=0; i<a.size(); i++) {\n             for(int j=i+1; j<a.size(); j++) {\n                   for(double x : solveType(a[i],a[j])) {  // possibilites of 2 numbers\n                         vector<double> other;\n                         other.push_back(x);\n                         for(int k=0; k<a.size(); k++) {\n                              if(k!=i && k!=j) other.push_back(a[k]);  // add remaining elements\n                         }\n                         if(solve(other)) return true;  // compute now for a.size() - 1 elements , reduce size of a \n                   }\n             }\n         }\n        return false;\n    }\n};\n```
['Math', 'C']