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.
come on guys. simple. if the element at the end is the smallest element, ie has to be shifted all the way left, you have to perform the last check individually outside the loop, something like
if (ar[0] > val){
ar[0] = val;
printArray(ar);
}
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 →
come on guys. simple. if the element at the end is the smallest element, ie has to be shifted all the way left, you have to perform the last check individually outside the loop, something like if (ar[0] > val){ ar[0] = val; printArray(ar); }