C# Brute-force Bitmasking Solution
Intuition\n-  Describe your first thoughts on how to solve this problem. Brute-force all possibilities: The first thought was to explore all potential combinati
# Intuition\n- <!-- Describe your first thoughts on how to solve this problem. -->Brute-force all possibilities: The first thought was to explore all potential combinations of good and bad people. Given that  n <= 15, there are at most 2^15 configurations, making it manageable to test each possibility.\n- Use bitmasking: Bitmasking allows efficient representation and manipulation of different configurations. Each bit in an integer represents whether a person is good (1) or bad (0), and we can iterate through all configurations using bitwise operations.\n- Validate configurations: For each bitmask configuration, check if it aligns with the statements made by the "good" people in that configuration. If all statements are consistent, consider the configuration valid.\n- Track the maximum: Keep a running maximum of the number of "good" people across all valid configurations.\n___\n# Approach\n<!-- Describe your approach to solving the problem. -->//  MaximumGood method:\n//  *Loops through all possible configurations using a bitmask.\n//  *Checks if the current configuration is valid by calling IsValidConfiguration.\n//  *If valid, counts the number of good people in this configuration using CountGoodPeople and updates maxGood.\n//  IsValidConfiguration Method:\n//  *Iterates through each person and checks if their statements are consistent with the assumption that they are good.\n//  *If any statement contradicts the current configuration, the method returns false.\n//  CountGoodPeople Method: Simply counts the number of set bits in the bitmask, representing the number of good people.\n___\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->O(2^n x n^2), where:\n2^n represents all possible bitmask configurations for \'n\' people.\nFor each configuration, we validate if it is consistent by checking n x n elements in the \'statements\' matrix.\n___\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->O(1), aside from the input size and teh recursive call stack used. The space used by variables remains constant since the bitmask is an integer. The input space is O(n^2) for the statements array.\n___\n\n# Code\n```csharp []\npublic class Solution {\n    public int MaximumGood(int[][] statements) {\n        int n = statements.Length;\n        int maxGood = 0;\n\n        // Iterate through all possible bitmask configurations (2^n)\n        for (int mask = 0; mask < (1 << n); mask++) {\n            if (IsValidConfiguration(mask, statements, n)) {\n                // Count the number of good people in the current bitmask\n                int countGood = CountGoodPeople(mask, n);\n                maxGood = Math.Max(maxGood, countGood);\n            }\n        }\n        \n        return maxGood;\n    }\n\n    // Function to check if the current bitmask configuration is valid\n    private bool IsValidConfiguration(int mask, int[][] statements, int n) {\n        for (int i = 0; i < n; i++) {\n            // If person i is good in the current mask\n            if ((mask & (1 << i)) != 0) {\n                for (int j = 0; j < n; j++) {\n                    if (statements[i][j] == 2) continue; // No statement made\n                    bool personJIsGood = (mask & (1 << j)) != 0;\n                    // Check if the statement aligns with the bitmask\n                    if ((statements[i][j] == 1 && !personJIsGood) || \n                        (statements[i][j] == 0 && personJIsGood)) {\n                        return false; // Invalid configuration\n                    }\n                }\n            }\n        }\n        return true; // All statements are consistent\n    }\n\n    // Function to count the number of good people in the bitmask\n    private int CountGoodPeople(int mask, int n) {\n        int count = 0;\n        for (int i = 0; i < n; i++) {\n            if ((mask & (1 << i)) != 0) {\n                count++;\n            }\n        }\n        return count;\n    }\n}\n```
['Array', 'Bit Manipulation', 'Bitmask', 'C#']