Diwali Offer!Flat 20% OFF
Enroll Now
PrakalpanaLive online tech training

191. Minimum Number of Arrows to Burst Balloons

MediumDay 56 of 60Greedy & Intervals

Balloons are taped to a wall, and balloon i spans the horizontal range points[i] = [start, end]. An arrow shot straight up at position x bursts every balloon with start <= x <= end. Return the minimum number of arrows needed to burst all balloons.

Example 1
Input: points = [[10,16],[2,8],[1,6],[7,12]]
Output: 2
Shoot at x = 6 (bursts [2,8] and [1,6]) and at x = 11 (bursts [10,16] and [7,12]).
Example 2
Input: points = [[1,2],[3,4],[5,6],[7,8]]
Output: 4
Constraints
  • 1 <= points.length <= 10^5
  • points[i].length == 2
  • -2^31 <= start < end <= 2^31 - 1
Hints
Frequently asked at: Amazon, Meta, Microsoft
Ctrl + Enter runs the examples

Not sure what to learn next?

A 1-on-1 session with an industry mentor and a roadmap built for you. How it works

  1. 1Discuss your goals
  2. 2Get a personal plan
  3. 3Start learning
Book for β‚Ή200/ 30 min