FastPrepPlace a Lamp to Cover the Most Objects
Problems/Place a Lamp to Cover the Most Objects

Place a Lamp to Cover the Most Objects

ZipRecruiter logoZipRecruiter● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A ZipRecruiter new-grad OA report describes sorted unique object coordinates, an integer lamp with a radius, maximizing the covered objects, and the example [-5,3,4,9] with radius 5 whose best coordinate is -1. We supplied the rule that ties go to the smallest coordinate, and the limits. Our version is about 93% the same as the reported question.

objects contains unique coordinates in strictly increasing order. A lamp at integer coordinate x illuminates every object whose distance from x is at most radius.

Return an integer lamp coordinate that illuminates the most objects, breaking ties by the smallest coordinate.

Function

bestLampCoordinate(objects: int[], radius: int) → int

Examples

Example 1

objects = [-5,3,4,9]radius = 5return = -1

The window [-5,4] is covered by lamp coordinate -1 and contains three objects.

Example 2

objects = [7]radius = 2return = 5

The smallest lamp coordinate covering the object is five.

Constraints

  • 1 <= objects.length <= 100000
  • -1000000000 <= objects[i] <= 1000000000
  • 0 <= radius <= 1000000000

More ZipRecruiter Online Assessment questions

  • Four-Level Banking System with Scheduled PaymentsOA · Seen Oct 2026
  • Count Three-Digit Numbers with Distinct DigitsOA · Seen Oct 2024
  • Longest Frequency-Bounded SubarrayOA · Seen Oct 2024
  • Minimum Changes to Draw a YOA · Seen Oct 2024
  • Apply Binary State OperationsOA · Seen Sep 2024
  • Simulate Orchard Rot SpreadOA · Seen Sep 2024
  • Compare Odd- and Even-Index SumsOA · Seen Sep 2024
  • Coordinate Removals with Column GravityOA · Seen Sep 2024
  • Lexicographically Smallest End ReversalOA · Seen Sep 2024
  • Recursively Expanded Shell Command CountsOA · Seen Sep 2024

Similar questions at other companies

  • Count Subarrays With Product Equal to KSalesforce · OASalesforce interview questions
  • Count Belt Sections With K Fruit Pairs (Forward Deployed Engineer)Boston Consulting Group · OABoston Consulting Group interview questions
  • K Smallest SubstringAkuna Capital · OAAkuna Capital interview questions
  • Shortest SubstringRippling · OARippling interview questions
  • Calculate Difference Value 🍧DoorDash · OADoorDash interview questions
  • Maximum Consecutive Sum Within a ThresholdIndeed · OAIndeed interview questions
  • Fastest Average Speed over a Rolling KilometerOptiver · OAOptiver interview questions
  • Maximum Requests in a Time WindowIBM · OAIBM interview questions
  • Maximum Events in a 60-Second WindowMarshall Wace · OAMarshall Wace interview questions
  • Subarray Product Less Than KApple · PHONE SCREENApple interview questions

ZipRecruiter interview experiences

  • ZipRecruiter SWE OA, Level Not Reported: 23 Experiences
  • ZipRecruiter SWE Intern OA Scores: 4 Experiences
  • ZipRecruiter SWE New Grad OA: 9 Experiences
All ZipRecruiter interview questionsSee ZipRecruiter hiring insights
Saved
class Solution {
    public int bestLampCoordinate(int[] objects, int radius) {
        // Write your code here.
    }

}
Checking account…