An admin panel lets a user share access with someone else, but only with permissions they have themselves. The user's permissions are a bit mask mask.
Write narrowerSets(mask) that returns every mask that only uses bits from mask (its submasks, including mask itself and 0), sorted from largest to smallest.
Input: mask = 5 Output: [5,4,1,0]
5 is 101. Its submasks are 101, 100, 001, and 000.
Input: mask = 0 Output: [0]
With no permissions, the only option is none.
0 <= mask <= 2^30mask has at most 10 bits set.Run 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 #677 Every Narrower Permission Set. 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.