Last active
June 18, 2017 23:28
-
-
Save stellamiranda/70cf307df59fc3b19e4a6787e19bf09c to your computer and use it in GitHub Desktop.
Birthday Cake Candles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Challenge: Birthday Cake Candles - HakerRank | |
# Author: Stella Miranda | |
# Colleen is turning n years old! Therefore, 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. | |
# Constraints | |
# 1 <= n <= 10^5 | |
# 1 <= height_i <= 10^7 | |
# Output Format | |
# Print the number of candles Colleen blows out on a new line. | |
# Sample Input 0 | |
4 | |
3 2 1 3 | |
# Sample Output 0 | |
2 | |
n = gets.strip.to_i | |
height = gets.strip | |
height = height.split(' ').map(&:to_i) | |
height.sort! | |
puts height.count(height[n-1]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment