Answered step by step
Verified Expert Solution
Question
1 Approved Answer
pls write the codes as simple as possible. Thank you. java Colleen is turning n years old! She has n candles of various heights on
pls write the codes as simple as possible.
Thank you.
java
Colleen is turning n years old! She has n candles of various heights on her cake, and candle i has height height_i. Because the taller candles tower over the shorter ones, Colleen can only blow out the tallest candles. Given the height_i for each individual candle, find and print the number of candles she can successfully blow out. Input Format The first line contains a single integer, n, denoting the number of candles on the cake. The second line contains n space-separated integers, where each integer i describes the height of candle i. Output Format Print the number of candles Colleen blows out on a new line. Sample Input 4 3 2 1 3 Sample Output 2 Explanation We have one candle of height 1, one candle of height 2, and two candles of height 3. Colleen only blows out the tallest candles, meaning the candles where height = 3. Because there are 2 such candles, we print 2 on a new lineStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started