и посмотреть медиа
Golang | LeetCode
и посмотреть медиа
LeetCode tasks in Golang. Solutions with code and explanations.
LeetCode tasks in Golang. Solutions with code and explanations.
AI bot for text-to-speech and voice cloning in Telegram. Create audio using neural network quickly and easily.
Channel with solutions to popular LeetCode tasks in Go. Focus on optimized algorithms, efficient memory usage, and idiomatic code. Helps prepare for technical interviews in companies that use Golang.
Задача: 1064. Fixed Point Сложность: medium Дан массив различных целых чисел arr, отсортированный в порядке возрастания. Верните наименьший индекс i, который удовлетворяет условию arr[i] == i. Если такого индекса нет, верните -1. Пример: Input: arr = [-10,-5,0,3,7] Output: 3 Explanation: For the given array, arr[0] = -10, arr[1] = -5, arr[2] = 0, arr[3] = 3, thus the output is 3. 👨💻 Алгоритм: 1⃣Инициализируйте значение left как 0, right как N - 1 и answer как -1. 2⃣Пока размер области поиска не равен нулю, то есть left mid, перейдите в левую часть, изменив right на mid - 1. 3⃣Верните answer. 😎 Решение: func fixedPoint(arr []int) int { left, right := 0, len(arr) - 1 answer := -1 for left
Открыть канал и посмотреть медиаOnly registered users can share their opinion.
Be the first to share your impression of this resource!