C++ Backtracking solution
\tif we have the array\n    [a, b, c, d]\n\n    and if we chose two numbers lets say we chose a and b, then all the possible operations are\n    a + b (1)\n    
\tif we have the array\n    [a, b, c, d]\n\n    and if we chose two numbers lets say we chose a and b, then all the possible operations are\n    a + b (1)\n    a - b (2)\n    b + a (3)\n    b - a (4)\n    a*b (5)\n    b*a (6)\n    a/b (7)\n    b/a (8)\n\n    but 1 and 3 are same and [5, 6] are same\n    so we count them only once\n\n    also for operations 7 and 8, we have to ensure that the denominator does not become 0\n    so if we pick a and b, and we apply any of the above operations between them, let the resulting number be x\n    so the newly generated array is\n    [x, b, c]\n\n    now again we apply the same on this array\n\n\n```\nclass Solution {\npublic:\n    const int eps = 1e-4;\n    vector<double> genPossibilities(double x, double y) {\n        vector<double> res = {x + y, x - y, y - x, x * y};\n        if (abs(y) > 0.000001) res.push_back(x / y);\n        if (abs(x) > 0.000001) res.push_back(y / x);\n        return res;\n    }\n\n    bool solve(vector<double> &a) {\n        int n = a.size();\n        if (n == 1) {\n            return abs(a[0] - 24.0) <= 0.000001;\n        }\n\n        for (int i = 0; i < n; i++) {\n            for (int j = i + 1; j < n; j++) {\n                vector<double> possibilities = genPossibilities(a[i], a[j]);\n                vector<double> temp;\n                for (int k = 0; k < n; k++) {\n                    if (k != i && k != j) temp.push_back(a[k]);\n                }\n                for (double x : possibilities) {\n                    vector<double> cur = temp;\n                    cur.push_back(x);\n                    bool res = solve(cur);\n                    if (res) return true;\n                }\n            }\n        }\n\n        return false;\n    }\n    bool judgePoint24(vector<int>& cards) {\n        vector<double> a(cards.begin(), cards.end());\n        return solve(a);\n    }\n};\n```
[]