๋ฌธ์ ํ์ด ์ธ์ด Kotlin ์ฝ๋ class Solution { fun solution(s: String): IntArray { val string = s.slice(2 until s.length - 2) val array = string.split("},{") val sortedArray = array.sortedBy { it.length } val answer = mutableListOf() for (e in sortedArray) { val splitString = e.split(',') for (num in splitString) { if (answer.contains(num.toInt()).not()) answer.add(num.toInt()) } } return answer.toIntArray..
๋ฌธ์ ํ์ด ์ธ์ด Kotlin ์ฝ๋ class Solution { fun solution(record: Array): Array { val history = arrayListOf() val name = mutableMapOf() val result = arrayListOf() for (e in record.iterator()) { val act = e.split(" ") when (act[0]) { "Enter" -> { name[act[1]] = act[2] history.add(Pair(act[0], act[1])) } "Leave" -> { history.add(Pair(act[0], act[1])) } "Change" -> { name[act[1]] = act[2] } } } history.map ..
ํ์ด ์ธ์ด Kotlin ์ฝ๋ fun solution(s: String): Int { var minLength = s.length for (i in 0 until s.length / 2) { var subString = s.slice(0..i) var answer = "" var cnt = 1 var last = 0 for (j in i + 1 until s.length - i step i + 1) { // ๋ง์ง๋ง Index ๋ฅผ ์ ์ฅํ๋ค. last = j + i + 1 // ๊ฐ์ SubString ์ธ ๊ฒฝ์ฐ ์ด๋ฅผ ์นด์ดํธํ๋ค. if (subString == s.slice(j..j + i)) cnt += 1 // ๋ค๋ฅธ SubString ์ธ ๊ฒฝ์ฐ else { if (cnt > 1) { // ์ซ์ + SubStri..