Question DSA-REC-0044
MediumWhat is the output of this code?
def perms(s):
if len(s) <= 1:
return [s]
out = []
for i, c in enumerate(s):
for p in perms(s[:i] + s[i+1:]):
out.append(c + p)
return out
r = perms("abc")
print(len(r), r[3])
- A.
6 bac
- B.
3 bca
- C.
Sign up free to see the answer and a step-by-step explanation.