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.
passing the challenge really depens to the enviroment , i have wrote below and did not pass for 2 first submit but in third submit it passed all test cases.
definsertionSort(arr):# Write your code herelen_arr=len(arr)iflen_arr==1:return0mid=len_arr// 2n=len_arr-midleft=arr[:mid]right=arr[mid:]answer=insertionSort(left)+insertionSort(right)count_left=0count_right=0foriinrange(len_arr):ifcount_left<midand\
(count_right>=norleft[count_left]<=right[count_right]):arr[i]=left[count_left]answer+=count_rightcount_left+=1elifcount_right<n:arr[i]=right[count_right]count_right+=1returnanswer
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Insertion Sort Advanced Analysis
You are viewing a single comment's thread. Return to all comments →
passing the challenge really depens to the enviroment , i have wrote below and did not pass for 2 first submit but in third submit it passed all test cases.