question: public static int [ ] deleteDuplicatedPages ( int [ ] pages ) { List < Integer > result = new ArrayList < > ( ) ; int lastInt = - 1 ; for ( Integer currentInt : pages ) { if ( lastInt != currentInt ) { result . add ( currentInt ) ; } lastInt = currentInt ; } int [ ] arrayResult = new int [ result . size ( ) ] ; for ( int i = 0 ; i < result . size ( ) ; i ++ ) { arrayResult [ i ] = result . get ( i ) ; } return arrayResult ; }
target:  Transforms (0,1,2,2,3) to (0,1,2,3) 