Swap element with last element so that remove from arr [ ] can be done in O ( 1 ) time
int size = arr . size ( ) ; Integer last = arr . get ( size - 1 ) ; Collections . swap ( arr , index , size - 1 ) ;