N๊ณผ M (1) ๋ฌธ์ ํ์ด ์ธ์ด Kotlin ์ฝ๋ import java.util.* lateinit var visit: Array lateinit var input: Array var n: Int = 0 var m: Int = 0 fun main() = with(Scanner(System.`in`)) { n = nextInt() m = nextInt() visit = Array(n + 1) { 0 } input = Array(n + 1) { 0 } dfs(0) } fun dfs(depth: Int) { if (depth == m) { for (i in 0 until m) { print("${input[i]} ") } println() return } for (i in 0 until n) { if (vis..
๋ฌธ์ ํ์ด ์ธ์ด 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 ์ฝ๋ import java.util.* class Solution { fun solution(places: Array): IntArray { val answer = mutableListOf() val size = places.size for (place in places) { var check = 0 for (i in 0 until size) { for (j in 0 until size) { if (place[i][j] == 'P') { if (bfs(place, i, j, size).not()) { check = 1 break } } } if (check == 1) { break } } if (check == 1) answer.add(0) else answer..
๋ฌธ์ ํ์ด ์ธ์ด 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..