static boolean pairDiff(int ar[],int x){
  Arrays.sort(ar);
  int len=ar.length;
  for (int i=0, j=1; i < len && j < len; ) {
    if (i != j && ar[j] - ar[i] == x) {
      return true;
    }
 else     if (ar[j] - ar[i] < x) {
      j++;
    }
 else {
      i++;
    }
  }
  return false;
}

static boolean pairDiff ( int ar [ ] , int x ) { Arrays . sort ( ar ) ; int len = ar . length ; for ( int i = 0 , j = 1 ; i < len && j < len ; ) { if ( i != j && ar [ j ] - ar [ i ] == x ) { return true ; } else if ( ar [ j ] - ar [ i ] < x ) { j ++ ; } else { i ++ ; } } return false ; }
using sorting . if we use merge sort or heap sort then ( - ) ( nlogn ) in worst case . if we use quick sort then o ( n ^ 2 ) in worst case .
