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.
for i in range(n):
k =i
ele = arr[i]
while(k>0 and ele<arr[k-1]):
arr[k] = arr[k-1]
k = k-1
arr[k] = ele
if i!=0:
print(' '.join([str(x) for x in arr]))
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Insertion Sort - Part 2
You are viewing a single comment's thread. Return to all comments →
then you will like this
def insertionSort2(n, arr):