TypeScript & JavaScript | Beats 100% memory and time | Bitmask
\nTypeScript []\nfunction maximumGood(statements: number[][]): number {\n    const n: number = statements.length\n    let res: number = Number.MIN_SAFE_INTEGER\
![Capture.JPG](https://assets.leetcode.com/users/images/ec310cb4-4f96-49cf-9fb7-0a11b0f3e1d6_1695363889.9201026.jpeg)\n```TypeScript []\nfunction maximumGood(statements: number[][]): number {\n    const n: number = statements.length\n    let res: number = Number.MIN_SAFE_INTEGER\n    outer:\n    for(let i = 0; i < 1 << n; i++){\n        for(let j = 0; j < n; j++){\n            for(let k = 0; k < n; k++){\n                if(statements[j][k] === 2) continue\n                if(i & (1 << j)){\n                    if(i & (1 << k)){\n                        if(statements[j][k] === 0) continue outer\n                    }\n                    else{\n                        if(statements[j][k] === 1) continue outer\n                    }\n                }\n            }\n        }\n        res = Math.max(res, bitCount(i))\n    }\n    return res\n}\n\nconst bitCount = (n: number) => {\n    n = n - ((n >> 1) & 0x55555555)\n    n = (n & 0x33333333) + ((n >> 2) & 0x33333333)\n    return ((n + (n >> 4) & 0xF0F0F0F) * 0x1010101) >> 24\n}\n```\n```JavaScript []\nfunction maximumGood(statements) {\n    const n = statements.length\n    let res = Number.MIN_SAFE_INTEGER\n    outer:\n    for(let i = 0; i < 1 << n; i++){\n        for(let j = 0; j < n; j++){\n            for(let k = 0; k < n; k++){\n                if(statements[j][k] === 2) continue\n                if(i & (1 << j)){\n                    if(i & (1 << k)){\n                        if(statements[j][k] === 0) continue outer\n                    }\n                    else{\n                        if(statements[j][k] === 1) continue outer\n                    }\n                }\n            }\n        }\n        res = Math.max(res, bitCount(i))\n    }\n    return res\n}\n\nconst bitCount = (n) => {\n    n = n - ((n >> 1) & 0x55555555)\n    n = (n & 0x33333333) + ((n >> 2) & 0x33333333)\n    return ((n + (n >> 4) & 0xF0F0F0F) * 0x1010101) >> 24\n}\n```\n\n\n\n# Code\n
['Bitmask', 'TypeScript', 'JavaScript']