Practice ยท 2 of 4
Binary search
CHALLENGE
Difficulty: beginner+25 XP
Implement static int BinarySearch(int[] sorted, int target) โ return the index of target in the ascending array, or -1. Keep the invariant: if the target exists, it stays within [lo, hi].
Press Submit to check your solution.
Back to lesson: Practice: Algorithm workshop