We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
# Enter your code here. Read input from STDIN. Print output to STDOUTisize=input()inp=input()inp=inp.split(" ")arr=[]foriininp:arr.append(int(i))defquicksort(arr):if(len(arr)<=1):returnarrfv=arr[0]left=[]right=[]equal=[fv]foriinrange(1,len(arr)):if(arr[i]<fv):left.append(arr[i])elif(arr[i]>fv):right.append(arr[i])else:equal.append(arr[i])left=quicksort(left)right=quicksort(right)new_ord_arr=left+equal+rightprint(*new_ord_arr)returnnew_ord_arrquicksort(arr)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Quicksort 2 - Sorting
You are viewing a single comment's thread. Return to all comments →
Python