Logo
TGCATALOG
Catalog Collections Blog
Kotlin | LeetCode

Kotlin | LeetCode

LeetCode problems and solutions in Kotlin.

No ratings
430
01.12.2026
430
01.12.2026
No ratings
430
01.12.2026
Safe redirect via bot
О канале

LeetCode problems and solutions in Kotlin.

Подписчиков —
Тематика Technology
Ссылка @easy_kotlin_task

We also recommend

Kekaton AI | Voiceover and voice clone
Kekaton AI | Voiceover and voice clone
Bot

AI bot for text-to-speech and voice cloning in Telegram. Create audio using neural network quickly and easily.

Description

LeetCode problem solutions in Kotlin. Optimized code for mobile developers and algorithm specialists.

Latest posts

Kotlin | LeetCode
Kotlin | LeetCode
🔒Открыть пост
и посмотреть медиа
Задача: 1059. All Paths from Source Lead to Destination Сложность: medium Учитывая ребра направленного графа, где edges[i] = [ai, bi] указывает на наличие ребра между вершинами ai и bi, и две вершины source и destination этого графа, определите, все ли пути, начинающиеся из source, заканчиваются в destination, то есть: существует ли хотя бы один путь из source в destination Если существует путь из source в node без исходящих ребер, то этот node равен destination. Количество возможных путей из source в destination - конечное число. Верните true тогда и только тогда, когда все пути из source ведут в destination. Пример: Input: n = 3, edges = [[0,1],[0,2]], source = 0, destination = 2 Output: false 👨💻 Алгоритм: 1⃣Построение графа и проверка путей: Построить граф на основе входных данных. Использовать поиск в глубину (DFS) для проверки наличия всех путей от вершины source до вершины destination. 2⃣Проверка конечности путей: Проверить, что из всех вершин, достижимых от source, либо исходят ребра, либо они являются вершиной destination. Убедиться, что из любой вершины, не являющейся destination, исходят хотя бы одно ребро. 3⃣Рекурсивная проверка конечности путей: Рекурсивно проверять, что все пути из source заканчиваются в destination, избегая циклов и проверяя конечность всех путей. 😎 Решение: class Solution { fun leadsToDestination(n: Int, edges: Array, source: Int, destination: Int): Boolean { val graph = mutableMapOf() for (edge in edges) { graph.computeIfAbsent(edge[0]) { mutableListOf() }.add(edge[1]) } val visited = IntArray(n) return dfs(graph, visited, source, destination) } private fun dfs(graph: MutableMap, visited: IntArray, node: Int, destination: Int): Boolean { if (visited[node] != 0) return visited[node] == 2 if (!graph.containsKey(node)) return node == destination visited[node] = 1 for (neighbor in graph[node]!!) { if (!dfs(graph, visited, neighbor, destination)) return false } visited[node] = 2 return true } } Ставь 👍 и забирай 📚 Базу знаний
Kotlin | LeetCode
FAQ

Open Kotlin | LeetCode in Telegram and press the Start button. No separate registration is required.

Yes. The service is designed to be straightforward: open the resource, follow the on-screen instructions and start using it.

No. You can use Kotlin | LeetCode directly in Telegram unless the resource description says otherwise.

Access depends on the resource. Check the current information in Telegram after opening Kotlin | LeetCode.

The exact features depend on the resource. Open Kotlin | LeetCode to see its current functions, content and access conditions.

Reviews for channel Kotlin | LeetCode

Log in to leave a review

Only registered users can share their opinion.

No reviews yet

Be the first to share your impression of this resource!

Similar resources

Loading
Switch to Light Theme
Home Catalog Collections Blog Login