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
4d
To burst all balloons by shooting arrows from left to right, determine the minimum number of arrows needed.
Iterate through the array and keep track of the maximum height of balloons that can be burst ...read more
Help your peers!
Add answer anonymously...
Top Deloitte Business Technology Analyst interview questions & answers
Popular interview questions of Business Technology Analyst
Top HR questions asked in Deloitte Business Technology Analyst
>
Deloitte Business Technology Analyst Interview Questions
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app