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 ascending order to make it easier to determine the minimum number of arrows neede...read more
Help your peers!
Add answer anonymously...
Oracle Full Stack Developer interview questions & answers
A Full Stack Developer was asked Q. Implement a few design patterns.
A Full Stack Developer was asked Q. Bursting Balloons Problem Given an array ARR of size N, where each element repre...read more
A Full Stack Developer was asked Q. Root to Leaf Path Problem Statement Given a binary tree with 'N' nodes numbered ...read more
Popular interview questions of Full Stack Developer
A Full Stack Developer was asked Q1. Implement a few design patterns.
A Full Stack Developer was asked Q2. Bursting Balloons Problem Given an array ARR of size N, where each element repre...read more
A Full Stack Developer was asked Q3. Root to Leaf Path Problem Statement Given a binary tree with 'N' nodes numbered ...read more
Stay ahead in your career. Get AmbitionBox app


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
AmbitionBox Awards
Get AmbitionBox app

