Piet Souris wrote:Did you figure out the answer to your question?
In your code, the first arraylist printed is the arraylist after the first switch from element 1 and element 0.
Now, in that first list, since 4 > 1, no switch took place and so it looks as if the inputlist is printed. In the second arraylist, 4 > 3, so these get swapped and therefore it seems as if now the inputlist is NOT shown.
In the snippet that I gave, you can follow exactly what happens during the sort.
Without what you have pointed out to me, I would be clueless till today. Thank you so much.
Now, I tried to put in :
But, it will be printed with the brackets. Now, there are solutions offered by stackoverflow like this one
https://stackoverflow.com/questions/32774059/output-arraylist-to-string-without-brackets-appearing
I just wonder if there is anything that can be added to the code that it will print out the array without what is suggested in SO or another way to do this insertion sort without adding those lines above ?
Really, i find all these hackerRank questions very tricky but once again thank you all the great people here.