ํผ๋ก๋
-
[Programmers] Lv2. ํผ๋ก๋(kotlin)SW Test/Programmers 2022. 10. 22. 17:07
๋ฌธ์ ์์ ํ์ด ๋ฐฑํธ๋ํน ๊ธฐ๋ฒ์ ์ด์ฉํ๋ฉด ์์ฝ๊ฒ ํ ์ ์์ต๋๋ค. import kotlin.math.* class Solution { var answer = -1 fun getResult(k: Int, dungeons: Array, check: List){ var flag = false for(i in 0 until check.size){ if(!check[i] && k >= dungeons[i][0]){ flag = true getResult(k-dungeons[i][1], dungeons, check.toMutableList().apply{ this[i] = true }) } } if(!flag){ answer = max(answer, check.count{it}) } } fun solution(k:..