1969. Minimum Non-Zero Product of the Array Elements
https://leetcode.com/problems/minimum-non-zero-product-of-the-array-elements
Description
You are given a positive integer p
. Consider an array nums
(1-indexed) that consists of the integers in the inclusive range [1, 2p - 1]
in their binary representations. You are allowed to do the following operation any number of times:
Choose two elements
x
andy
fromnums
.Choose a bit in
x
and swap it with its corresponding bit iny
. Corresponding bit refers to the bit that is in the same position in the other integer.
For example, if x = 1101
and y = 0011
, after swapping the 2nd
bit from the right, we have x = 1111
and y = 0001
.
Find the minimum non-zero product of nums
after performing the above operation any number of times. Return this product modulo 109 + 7
.
Note: The answer should be the minimum product before the modulo operation is done.
Example 1:
Example 2:
Example 3:
Constraints:
1 <= p <= 60
ac
Last updated