- array-rearrange, Arrays, Binary Search, Searching

Rearrange Array to find K using Binary Search algorithm without sorting

  #include using namespace std;  void Rearrange(int arr[], int K, int N){        int ans[N + 1];              int f = -1;      for (int i = 0; i < N; i++) {        ans[i] = -1;    }          K = find(arr, arr + N, K) - arr;                  vector smaller, greater;          for (int i = 0; i < N; i++) {                  if (arr[i] < arr[K])            smaller.push_back(arr[i]);                  else if (arr[i] > arr[K])            greater.push_back(arr[i]);    }      int low = 0, high = N – 1;              while (low