class Solution { public: void insertionSort(int arr[], int n) { int value,hole; for(int i=0;i<n;i++){ value=arr[i];hole=i; while(hole>0&&arr[hole-1]>value){ arr[hole]=arr[hole-1]; hole--; } arr[hole]=value; } } };
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