728x90

레벨1 K번째 수

def solution(array, commands):
    answer = []
    cut=[]
    for i in range(len(commands)):
        for r in range(commands[i][0]-1,commands[i][1]):
            cut.append(array[r])
        
        cut = sorted(cut)        
        answer.append(cut[commands[i][2]-1])
        cut=[]
    return answer

레벨2 가장 큰 수

def solution(numbers):

    a=[]
    c=''
    for i in numbers:
        a.append([(str(i)*4)[0:4],str(i)])
    a=sorted(a,reverse=True)
    for i in range(len(a)):
        c+=a[i][1]
    if int(c)==0:
        return '0'

    return c

레벨2 H-Index

def solution(citations):
    
    
    while citations:
        a=citations.index(min(citations))
        b=citations.pop(a)
        
        if len(citations)+1 <= b:
            return len(citations)+1
            break
        
    return 0

 

728x90

+ Recent posts