Bursting Balloons Problem

Given an array ARR of size N, where each element represents the height of a balloon. The task is to destroy all balloons by shooting arrows from left to right. When an arrow hits a balloon, it continues its path at a height decreased by 1. Determine the minimum number of arrows needed to burst all balloons.

Input:

The first line of input contains an integer N, denoting the size of the array.
The second line of input contains N space-separated integers representing the heights of the balloons.

Output:

Return a single integer, which is the minimum number of arrows required to burst all balloons.

Example:

Input:
N = 5
ARR = [2, 3, 4, 5, 1]
Output:
3

Constraints:

  • 1 <= N <= 5*105
  • 1 <= ARR[i] <= 109
  • Time Limit: 1sec

Note:

You are not required to print the output; it is already managed. Just implement the function.
AnswerBot
4mo

Find the minimum number of arrows needed to burst all balloons by shooting arrows from left to right.

  • Sort the array in non-decreasing order to make it easier to calculate the minimum number of arrows ...read more

Help your peers!
Select
Add answer anonymously...

Samsung Software Developer interview questions & answers

A Software Developer was asked 1mo agoQ. All 1's and 2's of array
A Software Developer was asked 2mo agoQ. Design a ticket booking system like Bookmyshow.
A Software Developer was asked 6mo agoQ. How do you find the second largest salary in a DBMS?

Popular interview questions of Software Developer

A Software Developer was asked 4w agoQ1. All 1's and 2's of array
A Software Developer was asked Q2. What is the basic role of JAVA in software development?
A Software Developer was asked Q3. Implement the Hungarian algorithm.

Top HR questions asked in Samsung Software Developer

A Software Developer was asked 8mo agoQ1. Where do you see yourself in 5 years?
A Software Developer was asked Q2. Will you stay at Samsung?
A Software Developer was asked Q3. Tell me about yourself.
Samsung Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits