FastPrepRepair a Binary Search
Problems/Repair a Binary Search

Repair a Binary Search

Jefferies logoJefferies● EasyFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Jefferies online assessment on Codility. The task asks you to repair a binary search that never ends, with inclusive bounds, and any matching occurrence may be returned. Our exercise returns the last occurrence, which is a valid choice with a fixed result. It matches the upper-midpoint direction of the repair in the report. The report does not label an employment category, so this record uses full-time as the fallback. The screenshot of the source is not shown because an overlay hides the code.

You are given an integer array values sorted from smallest to largest and an integer target.

Return the last index at which target occurs. If the value is absent, return -1.

Your implementation must use binary search and must finish correctly even when the search boundaries are next to each other or values repeat.

Function

repairedBinarySearch(values: int[], target: int) → int

Examples

Example 1

values = [1,2,5,9,9]target = 5return = 2

The value 5 occurs at index 2.

Example 2

values = [1,2,5,9,9]target = 9return = 4

The target occurs at indices 3 and 4, so the last occurrence is index 4.

Example 3

values = []target = 7return = -1

An empty array contains no matching occurrence.

Constraints

  • 0 <= values.length <= 100000
  • -1000000000 <= values[i], target <= 1000000000
  • values is sorted in non-decreasing order.

More Jefferies Online Assessment questions

  • Maximum Income from Asset TradingOA · Seen Oct 2026

Similar questions at other companies

  • First Missing Number in a Consecutive ArrayArista Networks · OA · PHONE SCREENArista Networks interview questions
  • Floor Square Roots for an ArrayWells Fargo · OAWells Fargo interview questions
  • Find the First Matching Ordered EntryFigma · OAFigma interview questions
  • Minimum BeautyBloomberg LP · OABloomberg LP interview questions
  • Count Lamps Lighting Each PointAirbnb · OAAirbnb interview questions
  • Count Pairs of Overlapping SquaresCapital One · OACapital One interview questions
  • Minimum Operations to Make a SubsequenceGoogle · OAGoogle interview questions
  • Bank Accounts with Balance HistoryMeta · OAMeta interview questions
  • Split Array to Minimize the Largest SumInfosys · OAInfosys interview questions
  • Sliding Window MedianAuxoAI · OA
See Jefferies hiring insights
Saved
class Solution {
    public int repairedBinarySearch(int[] values, int target) {
        // Write your code here.
    }

}
Checking account…