강의로 돌아가기
Yeonchik

답좀 알려주세요 ㅠㅠ

def solution(arr, k):
answer = 0
cnt = 0
lst=len(arr)
min = 1000
a=[]
while cnt==k:
for i in range(lst):
for j in range(lst):
a = arr[i][j]

  a.sort()         

return answer
arr = [ [5,12,4,31 ] ,
[24,13,11,2] ,
[43,44,19,26] ,
[33,65,20,21] ]

print(solution(arr, 4))

중간에 하닥 포기 ㅠ

6 개의 답변
안은성

def solution(arr, k):
container = []
for i in arr:
container += i
container.sort()
return(container[k - 1])

이욱
def solution(arr, k):
    L = sum(arr, [])
    L.sort()
    return L[k-1]
Hyunwoo Park
def solution(arr, k):
    candidate_list = []
    for _ in range(k):
        min_val = 1000
        for nums in arr:
            for num in nums:
                if (num not in candidate_list) and num < min_val:
                    min_val = num
        candidate_list.append(min_val)
    answer = candidate_list[-1]
    return answer
이재훈
def solution(arr, k): return sorted([x for row in arr for x in row])[k - 1]
Jae Kyun Ko

def solution(arr, k):

list1 = []

for i in range(len(arr)) :

    for j in range(4) :

        list1.append(arr[i][j])

list2 = sorted(list1)

answer = list2[k-1]

return answer
안우진
def solution(arr, k):
    answer = []
    for row in arr:
        for i in row:
            answer.append(i)
    return sorted(answer)[k - 1]
답변 쓰기
이 입력폼은 마크다운 문법을 지원합니다. 마크다운 가이드 를 참고하세요.