IT 개발자_S

해커랭크 Birthday Cake Candles 본문

IT/알고리즘_Python

해커랭크 Birthday Cake Candles

Soso12 2020. 3. 10. 23:36
반응형

 

 

 

#!/bin/python3

 

import math

import os

import random

import re

import sys

 

# Complete the birthdayCakeCandles function below.

def birthdayCakeCandles(ar):

    ar.sort()

    ar.reverse()

    check = True

    result =0

    i =0

    while(check) :

        result +=1

        if(ar[i] ==ar[i+1]):

            i +=1

        else :

            return result

            check =False

            break

 

if __name__ == '__main__':

    fptr = open(os.environ['OUTPUT_PATH'], 'w')

 

    ar_count = int(input())

 

    ar = list(map(intinput().rstrip().split()))

 

    result = birthdayCakeCandles(ar)

 

    fptr.write(str(result) + '\n')

 

    fptr.close()

------------------------------------

해당 입력시 런타임에러..

 

해결방안 ?

 

def birthdayCakeCandles(ar):

   return ar.count(max(ar))

사용 해결!

반응형

'IT > 알고리즘_Python' 카테고리의 다른 글

해커랭크 Breaking the Records  (0) 2020.03.22
해커랭크 Kangaroo PYTHON  (0) 2020.03.13
해커랭크 Apple and Orange  (0) 2020.03.12
해커랭크 Grading Strudents  (0) 2020.03.12
해커랭크 TIME Conversion python  (0) 2020.03.12
Comments