binarySearch static method
Implementation
static int binarySearch(List<int> arr, int value, [int start = 0, int? end]) {
late int mid;
end ??= arr.length - 1;
while (start <= end!) {
mid = start + ((end - start) / 2).round();
if (arr[mid] == value) return mid;
if (arr[mid] < value) {
start = mid + 1;
} else {
end = mid - 1;
}
}
return -1;
}