Count Lamps Lighting Each Point
Updated
Problem statement
Given a 2D integer array lamps and an integer array points, return an integer array answer where answer[j] is the number of lamps that light the position points[j].
All lamps and points are on one number line. Lamp i lights every position x with lamps[i][0] <= x <= lamps[i][1], so both ends of its range are lit.
Each row of lamps is its own lamp. If two rows are equal, both lamps count.
Function
lampsPerPoint(lamps: int[][], points: int[]) → int[]Examples
Example 1
lamps = [[2,6],[4,9],[9,12]]points = [5,9,1,12]return = [2,2,0,1]5is inside[2, 6]and[4, 9], so2.9is the right end of[4, 9]and the left end of[9, 12], so2.1is left of every lamp, so0.12is the right end of[9, 12]only, so1.
Example 2
lamps = [[3,3],[1,5],[1,5]]points = [3,5,3,0]return = [3,2,3,0]Position 3 is lit by the one-point lamp [3, 3] and by both copies of [1, 5], so it gets 3 each time it appears. Position 5 is lit only by the two copies of [1, 5], and 0 is lit by none.
Example 3
lamps = [[0,100000]]points = [0,100000,50000]return = [1,1,1]The one lamp runs from 0 to 100000, so it lights every allowed position, and each of the three points gets 1.
Constraints
1 <= lamps.length <= 10^5lamps[i].length == 20 <= lamps[i][0] <= lamps[i][1] <= 10^51 <= points.length <= 10^50 <= points[j] <= 10^5
More Airbnb Online Assessment questions
- Count Card Duel RoundsOA · Seen Nov 2026
- Simulate Orchard Rot SpreadOA · Seen Nov 2026
- Sort Adjacent PairsOA · Seen Nov 2026
- In-Memory File SystemOA · Seen Nov 2026
- Task Management SystemOA · Seen Nov 2026
- Recipe Management SystemOA · Seen Nov 2026
- Progressive Banking SystemOA · Seen Nov 2026
- Credit Accounts with Scheduled TransfersOA · Seen Oct 2026
- Parcel Attribute Store with TTLOA · Seen Oct 2026
- Parcel Event TrackingOA · Seen Oct 2026
Similar questions at other companies
- Choose ContainersIMC Trading · OAIMC Trading interview questions
- Calculating QuantilesIndeed · OAIndeed interview questions
- Count Lamps Lighting Each PointCapital One · OACapital One interview questions
- Minimum Cost to Make Array EqualWalmart · OAWalmart interview questions
- Subscription and Usage-Based Billing CalculatorStripe · OAStripe interview questions
- Maximum Interactive Team SizeMicrosoft · OAMicrosoft interview questions
- Linear InterpolatorTwo Sigma · OATwo Sigma interview questions
- Minimum Seats for One-Way Car PoolingSquadStack.ai · OA
- Find Sum of BeautiesAmazon · OA
- Minimize Maximum Group DifferenceDRW · OADRW interview questions
Airbnb interview experiences
- Airbnb OA · November 2026
- Airbnb Campus and Full-Time SWE OA / Interviews: 9 Experiences
- Airbnb Intern Phone Interviews: 21 Experiences (Part 7 of 7)
- Airbnb Intern OA and Phone Screens: 17 Experiences (Part 6 of 7)
- Airbnb Intern OA and Onsite Rounds: 16 Experiences (Part 5 of 7)
- Airbnb Intern OA, Diplomacy Game: 19 Experiences (Part 4 of 7)