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
🔒Открыть пост
и посмотреть медиа
Задача: 340. Longest Substring with At Most K Distinct Characters Сложность: medium Дана строка s и целое число k. Верните длину самой длинной подстроки s, которая содержит не более k различных символов. Пример: Input: n = 27 Output: true Explanation: 27 = 3^3 👨💻 Алгоритм: 1⃣Инициализация Используйте два указателя (left и right) для отслеживания текущего окна в строке. Создайте словарь для отслеживания количества каждого символа в текущем окне. Инициализируйте переменные для хранения максимальной длины подстроки (max_length). 2⃣Раздвижение окна Перемещайте правый указатель (right) по строке и обновляйте словарь. Если количество различных символов в словаре превышает k, перемещайте левый указатель (left) вправо, уменьшая счетчик символов, пока количество различных символов снова не станет меньше или равно k. 3⃣Обновление максимальной длины На каждом шаге проверяйте и обновляйте максимальную длину подстроки, если текущее окно содержит не более k различных символов. В конце верните максимальную длину подстроки. 😎 Решение: class Solution { fun lengthOfLongestSubstringKDistinct(s: String, k: Int): Int { var left = 0 var right = 0 val charCount = mutableMapOf() var maxLength = 0 while (right < s.length) { charCount[s[right]] = charCount.getOrDefault(s[right], 0) + 1 while (charCount.size > k) { charCount[s[left]] = charCount[s[left]]!! - 1 if (charCount[s[left]] == 0) { charCount.remove(s[left]) } left++ } maxLength = maxOf(maxLength, right - left + 1) right++ } return maxLength } } Ставь 👍 и забирай 📚 Базу знаний
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