Question DSA-ARR-0064
HardWhat is the output of this code?
a = [1, 2, 3, 4, 5, 6, 7]
k = 3
def rev(l, r):
while l < r:
a[l], a[r] = a[r], a[l]
l += 1; r -= 1
n = len(a)
rev(0, n - 1); rev(0, k - 1); rev(k, n - 1)
print(a)
- A.
[5, 6, 7, 1, 2, 3, 4]
- B.
[3, 2, 1, 7, 6, 5, 4]
- C.
Sign up free to see the answer and a step-by-step explanation.