recursion, backtraking, all possible iterations easy explained
Intuition\nwe will select two pair of elemets and  perform all given mathematical operations on that pair and then we store them in in  a vector and puch the re
# Intuition\nwe will select two pair of elemets and  perform all given mathematical operations on that pair and then we store them in in  a vector and puch the result of each operation step by step by pushing them into a newly created vector with consists the calculated result and all no\'s except pair whose result is pushed into the vector\n\n# Approach\nwe run for loop nested i,j and k we take i,j to as a pair each time to calculate the result we push it into the nelwy created list and the we again check it condition satisfies  \n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->O(n^3 * n!*(n-1)! * 3^(n-1))\nn^3 for 3 for loop\nn!*(n-1)!*3^(n-1) for recurssion call\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->O(n^2)\n\n# Code\n```\nclass Solution {\npublic:\nvector<double>fill(double a,double b){\n// all operations\n  vector<double>v={a+b,a-b,b-a,a*b};\n    if(a!=0) v.push_back(b/a);\n    if(b!=0) v.push_back(a/b);\n  \n  return v;\n}\nbool check(vector<double>&newl){\n  if(newl.size()==1){\n // We have only one number left, check if it is approximately 24.\n// will have only one element after appling operations    \nreturn abs(newl[0]-24)<=0.1;\n// <=0.1 is for upto 1 decimal places for approximation\n  }\n  for(int i=0;i<newl.size();i++){\n    for(int j=i+1;j<newl.size();j++){\n            vector<double> newList;\n                for (int k = 0; k < newl.size(); k++) {\n// pushing every element except i , j as we pus operation result of i,j\n                    if (k != j && k != i) {\n                        newList.push_back(newl[k]);\n                    }\n                }\n                \n    \n   vector<double>res;\n// new vector to store all possible obtained result\n     res=fill(newl[i],newl[j]);\n           for(int l=0;l<res.size();l++){\n// push one operation\n             newList.push_back(res[l]);\n// check if the array is meeting requirement\n             if(check(newList)) return true;\n// if not pop last push\n               newList.pop_back();\n         }\n  }}\n  return false;\n}\n    bool judgePoint24(vector<int>& cards) {\n        vector<double> newl(cards.begin(), cards.end());\n        return check(newl);\n    }\n};\n```
['C++']