Fix off-by-one error (fixes #3248) (#3250)

This commit is contained in:
vie02 2022-09-07 13:01:22 +07:00 committed by GitHub
parent 69d0070c99
commit d22420fea8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,7 +31,7 @@ class BinarySearch implements SearchAlgorithm {
*/ */
@Override @Override
public <T extends Comparable<T>> int find(T[] array, T key) { public <T extends Comparable<T>> int find(T[] array, T key) {
return search(array, key, 0, array.length); return search(array, key, 0, array.length - 1);
} }
/** /**