Skip to content

Instantly share code, notes, and snippets.

@tshev
Last active July 6, 2020 20:35
Show Gist options
  • Save tshev/1ef0ae2701809318775c46228d9e41c8 to your computer and use it in GitHub Desktop.
Save tshev/1ef0ae2701809318775c46228d9e41c8 to your computer and use it in GitHub Desktop.
int const* custom_partition_point(int const* first, int const* last) {
while (last - first > 1) {
int const* middle = first + (last - first) / 2;
if (*(middle - 1) < *middle) {
last = middle - 1;
} else {
first = middle;
}
}
if (*first < *(first + 1)) {
return first;
}
return first + 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment