We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
#!/bin/python3importmathimportosimportrandomimportreimportsys## Complete the 'birthdayCakeCandles' function below.## The function is expected to return an INTEGER.# The function accepts INTEGER_ARRAY candles as parameter.#defbirthdayCakeCandles(candles):# Write your code heresorted_candles=sorted(candles,reverse=True)height_count={}forheightinsorted_candles:ifheightinheight_count:height_count[height]+=1else:height_count[height]=1tallest_candle=sorted_candles[0]returnheight_count[tallest_candle]if__name__=='__main__':fptr=open(os.environ['OUTPUT_PATH'],'w')candles_count=int(input().strip())candles=list(map(int,input().rstrip().split()))result=birthdayCakeCandles(candles)fptr.write(str(result)+'\n')fptr.close()
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Birthday Cake Candles
You are viewing a single comment's thread. Return to all comments →
My Solution.