https://leetcode.com/problems/shortest-path-with-alternating-colors/ fun shortestAlternatingPaths(n: Int, red_edges: Array<IntArray>, blue_edges: Array<IntArray>): IntArray { val answer : Array<IntArray> = Array(2){IntArray(n)} val finalAnswer = IntArray(n) for (i in 1 until n) { answer[0][i] = 2*n answer[1][i] = 2*n } val queue: Queue<Int> = ArrayDeque() queue.offer(0) while (!queue.isEmpty()) { val current = queue.remove() for (edge in red_edges) { if (edge[0] ==…
Read more