After finding reciprocal , check if the reciprocal is in A . P . To check for A . P . , first Sort the reciprocal array , then check difference between consecutive elements
Collections . sort ( rec ) ; int d = ( int ) rec . get ( 1 ) - ( int ) rec . get ( 0 ) ; for ( int i = 2 ; i < n ; i ++ ) if ( rec . get ( i ) - rec . get ( i - 1 ) != d ) return false ; return true ; }