Contains all the array elements
List < Integer > nums = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { nums . add ( arr [ i ] ) ; } int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) {