Logo
TGCATALOG
Catalog Collections Blog
Kotlin | LeetCode

Kotlin | LeetCode

Задачи LeetCode и решения на Kotlin.

No ratings
89
10.09.2026
89
10.09.2026
No ratings
89
10.09.2026
Safe redirect via bot
О канале

Задачи LeetCode и решения на Kotlin.

Подписчиков 1,706
Тематика Technology
Язык English
Ссылка t.me/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 задач на Kotlin. Оптимизированный код для мобильных разработчиков и алгоритмистов.

Latest posts

Kotlin | LeetCode
Kotlin | LeetCode
🔒Открыть пост
и посмотреть медиа
Задача: 1253. Reconstruct a 2-Row Binary Matrix Сложность: medium Даны следующие сведения о матрице с n столбцами и 2 строками: Матрица является двоичной, то есть каждый элемент матрицы может быть 0 или 1. Сумма элементов 0-й (верхней) строки задана как upper. Сумма элементов 1-й (нижней) строки задана как lower. Сумма элементов i-го столбца (индексированного 0) - colsum[i], где colsum - целочисленный массив длины n. Ваша задача - восстановить матрицу с upper, lower и colsum. Вернуть ее в виде двумерного целочисленного массива. Если существует более одного правильного решения, будет принято любое из них. Если правильного решения не существует, верните пустой двумерный массив. Пример: Input: upper = 2, lower = 1, colsum = [1,1,1] Output: [[1,1,0],[0,0,1]] 👨💻 Алгоритм: 1⃣Инициализируйте две строки матрицы длины n с нулями. 2⃣Пройдите по массиву colsum и распределите значения 2 по обеим строкам, уменьшая upper и lower. Пройдите по массиву colsum и распределите значения 1 по строкам, уменьшая соответствующие upper или lower. 3⃣Проверьте, что остатки upper и lower равны нулю. Если все шаги выполнены успешно, верните восстановленную матрицу, иначе верните пустую матрицу. 😎 Решение: class Solution { fun reconstructMatrix(upper: Int, lower: Int, colsum: IntArray): List • > { var upper = upper var lower = lower val n = colsum.size val top = IntArray(n) val bottom = IntArray(n) for (i in colsum.indices) { if (colsum[i] == 2) { if (upper > 0 && lower > 0) { top[i] = 1 bottom[i] = 1 upper-- lower-- } else { return emptyList() } } } for (i in colsum.indices) { if (colsum[i] == 1) { if (upper > lower) { if (upper > 0) { top[i] = 1 upper-- } else { return emptyList() } } else { if (lower > 0) { bottom[i] = 1 lower-- } else { return emptyList() } } } } if (upper == 0 && lower == 0) { return listOf(top.toList(), bottom.toList()) } else { return emptyList() } } } Ставь 👍 и забирай 📚 Базу знаний
Kotlin | LeetCode
Subscriber dynamics
+-0.1% last 30 days
Current
1,706
Month ago
1,707
Average growth
+0 / day
Updated
10 hours ago

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

News about neural networks, AI and voice bot. Relevant information for enthusiasts.

Channel

Funny memes, news and humor from the worldITfor relaxed reading.

Channel

Store of rare electronics: unique gadgets with fast delivery throughout Russia.

Channel
Switch to Light Theme
Home Catalog Collections Blog Login