Minimum Non-Zero Product of the Array Elements LeetCode solution in JavaScript
1var minNonZeroProduct = function (p) {2p = BigInt(p);34const MOD = BigInt(1e9 + 7);5const first = (1n << p) - 1n;67const half = first / 2n;89const second = powMOD(first - 1n, half);1011return (first * second) % MOD;1213function powMOD(num, exp) {14if (exp === 0n) return 1n;1516const tmp = powMOD(num, exp >> 1n);1718let res = (tmp * tmp) % MOD;1920if (exp % 2n) res = (res * num) % MOD;2122return res;23}24};