Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upOptimize method flip in SortUtils #1246
Open
Comments
StepfenShawn
added a commit
that referenced
this issue
May 6, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
static <T extends Comparable> void flip(T[] array, int left, int right) {
while (left <= right) {
swap(array, left++, right--);
}
}
Change 'left <= right' to 'left < right', can improve efficiency in some cases