class Solution { public: vector<int> diffWaysToCompute(string input) { vector<int> res; int n = input.size(); for(int i = 0; i < n; i++) { char c = input[i]; if(c < '0' || c > '9') { vector<int> left = diffWaysToCompute(input.substr(0,i)); vector<int> right = diffWaysToCompute(input.substr(i+1,n)); for(int l : left) { for(int r : right) { if(c == '+') { res.push_back(l + r); } else if (c == '-') { res.push_back(l - r); } else { res.push_back(l * r); } } } } } if(!res.size()) res.push_back(stoi(input)); return res; } };