You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//if size is less than or equal to 2 then the array is already sorted
if(n <= 2) return n;
int i,j;
//if first 2 elements are in pair the start checking from third element
if(a[0] == a[1]) i = j = 2;
else i = j = 1; //else start from 2nd element
while(j<n && i<n){
//increment j while we do not encounter an element which is greater than the preiously occured pair of elements before ith place, i.e. (i-1)the and (i-2)th element