why backtracking is not working ? can you guys help me ?
\nclass Solution {\npublic:\n    int solve(vector<vector<int>> grid, int r, vector<int>&freq){\n\n\tint n = grid.size();\n\tint m = grid[0].size();\n\tint ans =
```\nclass Solution {\npublic:\n    int solve(vector<vector<int>> grid, int r, vector<int>&freq){\n\n\tint n = grid.size();\n\tint m = grid[0].size();\n\tint ans = 0;\n\tif(r == n)\n\t\treturn ans;\n    bool flag = 0; \n\tfor (int j = 0; j < m; j++)\n\t{\n\t\tif(freq[grid[r][j]]==0){\n\t\t\tfreq[grid[r][j]]++;\n\t\t\tans = max(ans, grid[r][j] + solve(grid, r + 1, freq));\n\t\t\tfreq[grid[r][j]]--; \n            flag = 1;\n\t\t}\n\t}\n        \n    if(flag==0)ans = max(ans, solve(grid, r + 1, freq)); \n\treturn ans; \n}\n\nint maxScore(vector<vector<int>> & grid){\n\n\tvector<int> freq(101, 0);\n\tint ans = -1;\n\tans = max(ans, solve(grid, 0, freq));\n\treturn ans; \n}\n    \n};\n// here is my solution, can anyone tell me , passing 513 / 545 \n```
[]