FastPrepMinimum Points Hitting Every Closed Interval
Problems/Minimum Points Hitting Every Closed Interval

Minimum Points Hitting Every Closed Interval

Google logoGoogle● MediumNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report defines closed sets [L,R] on a line and asks for the smallest set of points that touches all of them. Here the answer is the usual greedy one that picks right endpoints. Our version is about 96% the same as the reported question.

You are given a list of integer intervals [left,right]. Each interval includes both of its endpoints. Choose as few integer points as possible so that every interval contains at least one chosen point.

More than one set of points can be the smallest. Return the set this greedy method builds, in increasing order:

  1. Sort the intervals by right endpoint, smallest first. Break ties by left endpoint, smallest first.
  2. Go through the intervals in that order. If the current interval holds no chosen point yet, choose its right endpoint.

Function

minimumHittingPoints(intervals: int[][]) → int[]

Examples

Example 1

intervals = [[1,3],[2,5],[3,6]]return = [3]

Point 3 lies in every interval.

Example 2

intervals = [[1,2],[3,4],[2,3]]return = [2,4]

The first interval with no point yet gets point 2. The later interval [3,4] still has no point, so it gets point 4.

Example 3

intervals = []return = []

There are no intervals, so no points are needed.

Constraints

  • 0 <= intervals.length <= 200000.
  • -10^9 <= left <= right <= 10^9.

More Google Onsite Interview questions

  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Distinct Subset SumsONSITE INTERVIEW · Seen Nov 2026
  • Playlist With No Same Artist in a RowONSITE INTERVIEW · Seen Nov 2026
  • Delete Nodes and Return Forest RootsONSITE INTERVIEW · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • First and Last Target Position in a Mountain ArrayONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • 0/1 Knapsack with Weight and Volume LimitsONSITE INTERVIEW · Seen Nov 2026
  • Batched Subsequence Word MatchesONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Minimum Railway PlatformsMakeMyTrip.com · ONSITE INTERVIEW
  • Maximum Non-Overlapping IntervalsMicrosoft · ONSITE INTERVIEW
  • Minimum Removals for Non-Overlapping IntervalsByteDance · PHONE SCREEN · ONSITE INTERVIEW
  • Minimum Workers with Job AssignmentsLyft · ONSITE INTERVIEW
  • Minimum Removals for Non-Overlapping IntervalsBloomberg LP · ONSITE INTERVIEW
  • Maximum Compatible Time WindowsIBM · OA
  • Task SchedulingJP Morgan Chase · OA
  • Maximum Number of Events That Can Be AttendedSnowflake · PHONE SCREEN
  • Minimum Appointment Cancellations with a Required BreakMaven Clinic · PHONE SCREEN
  • Minimum Markers to Clear Line SegmentsHSBC · OA

Interview reports that mention this question

  • Google Early Career SWE Offer: 1 Experience

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
See Google hiring insights
Saved
class Solution {
    public int[] minimumHittingPoints(int[][] intervals) {
        // Write your code here.
    }
}
Checking account…