Traverse the given array and check if the difference between ith element and ( i - 1 ) th element is same or not
for ( int i = 2 ; i < n ; i ++ ) { if ( arr [ i ] - arr [ i - 1 ] != d ) { return false ; } } return true ; }