Why this quicksort code is giving runtime error in 2nd testcase? Unable to find the issue. Need help

import random

def swap(a, i, j):
t = a[i]
a[i] = a[j]
a[j] = t
return

def shuffle(a):
n = len(a)
for j in range(len(a)-1,0,-1):
idx = random.randint(0,j-1)
swap(a,idx,j)
return

def quicksort(a, s, e):
if s >= e:
return
p = e
i = 0
j = 0
while i < e and j < e:
if a[j] <= a[p]:
swap(a, i, j)
i += 1
j += 1
else:
j += 1
swap(a, p, i)
quicksort(a, s, i-1)
quicksort(a, i+1, e)
return

n = int(input())

a = [int(x) for x in input().split(" ")]

a = [int(i) for i in range(10000)]
a = a[::-1]
shuffle(a)

print(a)

quicksort(a, 0, len(a)-1)

print(a)

for x in a:
print(x, end = " ")
print()

Hi @keshari a working solution has been shared with you on the chat.
Please check it.

Hope this might help :slight_smile: