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.
definsertionSort2(n,arr):foriinrange(1,n):key=arr[i]j=i-1whilej>=0andkey<arr[j]:arr[j+1]=arr[j]j-=1arr[j+1]=keyprint(" ".join(map(str,arr)))# Example usage:n=int(input())arr=list(map(int,input().split()))insertionSort2(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 2
You are viewing a single comment's thread. Return to all comments →