и посмотреть медиа
Kotlin | LeetCode
и посмотреть медиа
LeetCode problems and solutions in Kotlin.
LeetCode problems and solutions in Kotlin.
AI bot for text-to-speech and voice cloning in Telegram. Create audio using neural network quickly and easily.
LeetCode problem solutions in Kotlin. Optimized code for mobile developers and algorithm specialists.
Задача: 28. Find the Index of the First Occurrence in a String Сложность: easy Учитывая две строки, needle и haystack, верните индекс первого вхождения needle в haystack или -1, если needle не является частью haystack. Пример: Input: haystack = "sadbutsad", needle = "sad" Output: 0 👨💻 Алгоритм: 1⃣ Используем встроенную функцию indexOf для поиска подстроки. 2⃣ Если подстрока найдена, возвращаем индекс ее первого вхождения. 3⃣ Если подстрока отсутствует, метод indexOf вернет -1. 😎 Решение: class Solution { fun strStr(haystack: String, needle: String): Int { return haystack.indexOf(needle) } } Ставь 👍 и забирай 📚 Базу знаний
Открыть канал и посмотреть медиаOnly registered users can share their opinion.
Be the first to share your impression of this resource!