Question DSA-SORT-0064
HardWhat is the output of this code?
def radix(a):
exp = 1
while max(a) // exp:
b = [[] for _ in range(10)]
for x in a:
b[x // exp % 10].append(x)
a = [x for bucket in b for x in bucket]
if exp == 10:
snap = a[:]
exp *= 10
return snap
print(radix([170, 45, 75, 90, 802, 24, 2, 66]))
- A.
[802, 2, 24, 45, 66, 170, 75, 90]
- B.
[170, 90, 802, 2, 24, 45, 75, 66]
- C.
Sign up free to see the answer and a step-by-step explanation.