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.
Hmm I also faced the issue. This is perhaps because the first element is not assigned in the loop you wrote. For me, I wrote another if statement to solve this special case and then the problem is solved.
it looks like this:
if (i < 0) {
ar[0] = v;
printarr(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 →
Hmm I also faced the issue. This is perhaps because the first element is not assigned in the loop you wrote. For me, I wrote another if statement to solve this special case and then the problem is solved. it looks like this:
if (i < 0) { ar[0] = v; printarr(ar); }