Question DSA-REC-0008
MediumWhat is the output of this code?
def perms(a, k=0):
if k == len(a):
return 1
c = 0
for i in range(k, len(a)):
a[k], a[i] = a[i], a[k]
c += perms(a, k + 1)
a[k], a[i] = a[i], a[k]
return c
print(perms([1, 2, 3]))
- A.
6
- B.
4
- C.
Sign up free to see the answer and a step-by-step explanation.