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 j in range(n - 1, 0, -1):
if arr[j - 1] > m:
arr[j] = arr[j - 1]
print(' '.join(str(x) for x in arr))
else:
arr[j] = m
print(' '.join(str(x) for x in arr))
return # Exit after inserting
# Insert at the beginning if m is the smallest
arr[0] = m
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 1
You are viewing a single comment's thread. Return to all comments →
this my python solution :.
def insertionSort1(n, arr): m = arr[n - 1]