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.
defcountSort(arr):# Write your code here# the number of element in the array_res is max(arr[:,0]) + 1length_arr_res=0foriinarr:ifint(i[0])>int(length_arr_res):length_arr_res=int(i[0])arr_res=[[]foriinrange(length_arr_res+1)]# find first half array and convert it to '-'.foriinrange(len(arr)//2):arr_res[int(arr[i][0])].append('-')# add last half arrayforiinrange(len(arr)//2,len(arr)):arr_res[int(arr[i][0])].append(arr[i][1])# print it outforiinarr_res:forjini:print(j,end=' ')
The Full Counting Sort
You are viewing a single comment's thread. Return to all comments →