A sprite editor stores a row of 32 pixels as a 32-bit mask, where bit 0 is the leftmost pixel. To flip the sprite horizontally, the bits must be reversed: bit 0 swaps with bit 31, bit 1 with bit 30, and so on.
mask is given as an unsigned value from 0 to 4294967295. Write mirrorMask(mask) that returns the reversed mask, also as an unsigned value.
Input: mask = 1 Output: 2147483648
Only bit 0 is on. After mirroring, only bit 31 is on, which is 2^31 = 2147483648.
Input: mask = 0 Output: 0
An empty row stays empty.
0 <= mask <= 4294967295Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #670 Mirror a 32-Bit Mask. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.