3133. Minimum Array End

Practice Minimum Array End for free on NudgeCode: Medium, Bit Manipulation pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

Build a strictly increasing array of n positive integers whose bitwise AND is exactly x. Return the smallest possible value of the last element.

Example

n = 3, x = 4  ->  6   ([4,5,6])
n = 2, x = 7  ->  15  ([7,15])

Constraints