check if the current element is equal to previous element .
if ( ele [ idx - 1 ] == ele [ idx ] ) { freq ++ ; idx ++ ; } else { cout << element << " ▁ " << freq << endl ; element = ele [ idx ] ; idx ++ ;