101
0/304
Loading content...
An IAM analytics team stores each user's enabled capabilities as an integer bitmask.
Table: user_permissions
Bitmask semantics:
Task: Produce exactly one row with these two metrics:
Output requirements:
Supported submission environments:
user_permissions:
| user_id | permissions |
|---------|-------------|
| 1 | 5 |
| 2 | 12 |
| 3 | 7 |
| 4 | 3 |[
{"common_perms":0,"any_perms":15}
]The shared-capability mask is 5 & 12 & 7 & 3 = 0, while the union mask is 5 | 12 | 7 | 3 = 15.
user_permissions:
| user_id | permissions |
|---------|-------------|
| 10 | 14 |
| 11 | 10 |
| 12 | 6 |
| 13 | 2 |[
{"common_perms":2,"any_perms":14}
]Bit 1 is present in every row, so common_perms is 2. Across all users, bits 1, 2, and 3 appear, so any_perms is 14.
user_permissions:
| user_id | permissions |
|---------|-------------|
| 21 | 1023 |
| 22 | 1023 |
| 23 | 1023 |[
{"common_perms":1023,"any_perms":1023}
]When every user has the same mask, both AND and OR equal that mask.
Constraints