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
🔒Открыть пост
и посмотреть медиа
Задача: 1503. Last Moment Before All Ants Fall Out of a Plank Сложность: medium У нас есть деревянная доска длиной n единиц. Некоторые муравьи ходят по доске, каждый муравей движется со скоростью 1 единица в секунду. Некоторые муравьи движутся влево, другие движутся вправо. Когда два муравья, движущиеся в разных направлениях, встречаются в какой-то точке, они меняют свои направления и продолжают двигаться дальше. Предполагается, что изменение направлений не занимает дополнительного времени. Когда муравей достигает одного из концов доски в момент времени t, он сразу же падает с доски. Дано целое число n и два целых массива left и right, обозначающие позиции муравьев, движущихся влево и вправо соответственно. Верните момент, когда последний(е) муравей(и) падает(ют) с доски. Пример: Input: n = 4, left = [4,3], right = [0,1] Output: 4 Explanation: In the image above: -The ant at index 0 is named A and going to the right. -The ant at index 1 is named B and going to the right. -The ant at index 3 is named C and going to the left. -The ant at index 4 is named D and going to the left. The last moment when an ant was on the plank is t = 4 seconds. After that, it falls immediately out of the plank. (i.e., We can say that at t = 4.0000000001, there are no ants on the plank). 👨💻 Алгоритм: 1⃣Инициализируйте переменную ans значением 0. 2⃣Итерация по массиву left и обновление ans значением num, если оно больше текущего значения ans. 3⃣Итерация по массиву right и обновление ans значением n - num, если оно больше текущего значения ans. Верните значение ans. 😎 Решение: class Solution { fun getLastMoment(n: Int, left: IntArray, right: IntArray): Int { var ans = 0 for (num in left) { ans = maxOf(ans, num) } for (num in right) { ans = maxOf(ans, n - num) } return ans } } Ставь 👍 и забирай 📚 Базу знаний
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