프로그래머스 탐욕법 체육복
·
코딩테스트(코틀린) 기초부터 연습
fun solution(n: Int, lost: IntArray, reserve: IntArray): Int { val lostP = mutableListOf() val reserveP = reserve.toMutableList() lost.forEach { if (reserve.contains(it)) { reserveP.remove(it) }else{ lostP.add(it) } } val lostDeafault = lostP.map { it } if(n>1){ lostP.indices.forEach { val value = lostDeafault[it] if(value == 1 ){ // 처음원소 if(reserveP.contains(2)){ lostP.remove(1) reserveP.remove..