λ¬Έμ νμ΄ μΈμ΄ Kotlin μ½λ import java.util.* import kotlin.math.abs lateinit var array: Array var n = 0 var cnt = 0 fun main() = with(Scanner(System.`in`)) { n = nextInt() array = Array(n) { 0 } nQueen(0) println(cnt) } fun nQueen(depth: Int) { // depthλ row if (depth == n) { println(depth) cnt++ return } for (i in 0 until n) { // iλ col array[depth] = i if (check(depth)) { nQueen(depth + 1) } } } fun ..
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..