✅backtracking solution || cPP
\n\n# Code\n\nclass Solution {\npublic:\n\n    int check(vector<vector<int>>& statements,vector<int>&vis,int n){\n        // for(int i:vis)cout<<i<<" ";\n      
\n\n# Code\n```\nclass Solution {\npublic:\n\n    int check(vector<vector<int>>& statements,vector<int>&vis,int n){\n        // for(int i:vis)cout<<i<<" ";\n        // cout<<endl;\n        for(int i=0;i<n;i++){\n            if(vis[i]==0)continue;\n            for(int j=0;j<n;j++){\n                // if(i==j)continue;\n                if(statements[i][j]!=2 && statements[i][j]!=vis[j])return 0;\n            }\n        }\n        // cout<<count(vis.begin(),vis.end(),1)<<endl;\n        return count(vis.begin(),vis.end(),1);\n    }\n\n    int solve(vector<vector<int>>& statements,int i,int n,vector<int>&vis){\n        if(i==n)return check(statements,vis,n);\n        int ans=0;\n        vis[i]=1;\n        ans=max(ans,solve(statements,i+1,n,vis));\n        vis[i]=0;\n        ans=max(ans,solve(statements,i+1,n,vis));\n        vis[i]=2;\n        return ans;\n    }\n\n    int maximumGood(vector<vector<int>>& statements) {\n        int n=statements.size();\n        vector<int>vis(n,2);\n        return solve(statements,0,n,vis);\n    }\n};\n```
['Array', 'Backtracking', 'C++']