1.
Summary Ranges (Easy)
You are given a sorted unique integer array nums
.
A range [a,b]
is the set of all integers from a
to b
(inclusive).
Return the smallest sorted list of ranges that cover all the numbers in the array exactly. That is, each element of nums
is covered by exactly one of the ranges, and there is no integer x
such that x
is in one of the ranges but not in nums
.
Each range [a,b] in the list should be output as:
"a->b"
ifa != b
"a"
ifa == b
2.
Merge Intervals (Medium)
Given an array of intervals
where intervals[i] = [start<i>, end<i>]
, merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the input.
3.
Insert Interval (Medium)
You are given an array of non-overlapping intervals intervals
where intervals[i] = [start<i>, end<i>]
represent the start and the end of the i
th interval and intervals
is sorted in ascending order by start
. You are also given an interval newInterval = [start, end]
that represents the start and end of another interval.
Insert newInterval
into intervals
such that intervals
is still sorted in ascending order by start<i>
and intervals
still does not have any overlapping intervals (merge overlapping intervals if necessary).
Return intervals
after the insertion.
Note that you don't need to modify intervals
in-place. You can make a new array and return it.
4.
Minimum Number of Arrows to Burst Balloons (Medium)
There are some spherical balloons taped onto a flat wall that represents the XY-plane. The balloons are represented as a 2D integer array points
where points[i] = [x<start>, x<end>]
denotes a balloon whose horizontal diameter stretches between x<start>
and x<end>
. You do not know the exact y-coordinates of the balloons.
Arrows can be shot up directly vertically (in the positive y-direction) from different points along the x-axis. A balloon with x<start>
and x<end>
is burst by an arrow shot at x
if x<start> <= x <= x<end>
. There is no limit to the number of arrows that can be shot. A shot arrow keeps traveling up infinitely, bursting any balloons in its path.
Given the array points
, return the minimum number of arrows that must be shot to burst all balloons.