void insertionSort(int n, vector<int> &arr) { for(int i=0 ; i<n ; i++) { int j=i; while(j>0 and arr[j]<arr[j-1]) { swap(arr[j],arr[j-1]); j--; } } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter