[C++] STL - next_permutation()
The brute force solution is generating all the permuntations of the students and calculates the score of this permutation and the students.\nTime Complexity : O
The brute force solution is generating all the permuntations of the students and calculates the score of this permutation and the students.\nTime Complexity : ``` O(n! * nm) ``` **n!** for permutations and **nm** for calculating score.\nSince , ``` n, m <= 8 ```  and  ``` 8! * 8 * 8 == 2,580,480 ```  which should pass.\n\n```\nclass Solution {\npublic:\n    int factorial(int n){\n        vector<int> arr(n + 1);\n        arr[0] = 1;\n        arr[1] = 1;\n        for (int i = 2; i <= n; i++){\n            arr[i] = arr[i - 1] * i;\n        }\n        return arr[n];\n    }\n    \n    int maxCompatibilitySum(vector<vector<int>>& students, vector<vector<int>>& mentors) {\n        int max_ = 0, curr_max = 0;\n        int row = students.size(), col = students[0].size();\n        int total_permutations = factorial(row);\n        for (int k = 0; k < total_permutations; k++){\n            \n            next_permutation(students.begin(), students.end());\n            curr_max = 0;\n            \n            for (int i = 0; i < row; i++){\n                for (int j = 0; j < col; j++){\n                    if (mentors[i][j] == students[i][j]) curr_max++;\n                }\n            }\n            \n            max_ = max(max_ , curr_max);\n        }\n        return max_;\n    }\n};\n```
[]