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.
#!/bin/python3importmathimportosimportrandomimportreimportsys## Complete the 'insertionSort1' function below.## The function accepts following parameters:# 1. INTEGER n# 2. INTEGER_ARRAY arr#definsertionSort1(n,arr):# Write your code hereforiinrange(n):j=icurr=arr[i]ifcurr<arr[j-1]:whilej>0andcurr<arr[j-1]:arr[j]=arr[j-1]j-=1print(*arr)ifj!=i:arr[j]=currprint(*arr)if__name__=='__main__':n=int(input().strip())arr=list(map(int,input().rstrip().split()))insertionSort1(n,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 →