Logo
TGCATALOG
Catálogo Selecciones Blog
Golang  LeetCode

Golang LeetCode

Tareas de LeetCode en Golang. Soluciones con código y explicaciones.

Sin valoraciones
376
02.12.2026
376
02.12.2026
Sin valoraciones
376
02.12.2026
Redirección segura vía bot
О канале

Tareas de LeetCode en Golang. Soluciones con código y explicaciones.

Подписчиков —
Тематика Tecnología
Ссылка @easy_golang_task

También te recomendamos

Kekaton AI  Voz en off y clon de voz
Kekaton AI Voz en off y clon de voz
Bot

bot de IA para clonar texto a voz y voz en Telegram. Cree audio utilizando la red neuronal de forma rápida y fácil.

Descripción

Canal con soluciones para tareas populares de LeetCode en Go. Concéntrate en algoritmos optimizados, uso eficiente de memoria y código idiomático. Ayuda a preparar entrevistas técnicas en empresas que utilizan Golang.

Últimas publicaciones

Golang  LeetCode
Golang LeetCode
🔒Открыть пост
и посмотреть медиа
Задача: 1345. Jump Game IV Сложность: hard Дан массив целых чисел arr, изначально вы находитесь на первом индексе массива. За один шаг вы можете прыгнуть с индекса i на индекс: - i + 1, где: i + 1 < arr.length. - i - 1, где: i - 1 >= 0. - j, где: arr[i] == arr[j] и i != j. Вернуть минимальное количество шагов, чтобы достичь последнего индекса массива. Обратите внимание, что нельзя прыгать за пределы массива в любой момент времени. Пример: Input: arr = [100,-23,-23,404,100,23,23,23,3,404] Output: 3 Explanation: You need three jumps from index 0 --> 4 --> 3 --> 9. Note that index 9 is the last index of the array. 👨💻 Алгоритм: 1⃣Построить граф, где ключи - значения из массива, а значения - списки индексов этих значений. Начать с первого индекса, добавив его в очередь текущего слоя и инициализировать набор посещенных индексов. 2⃣Выполнять BFS: для каждого индекса текущего слоя проверять соседние индексы (i + 1, i - 1 и все j, где arr[i] == arr[j]), добавляя непосещенные индексы в очередь следующего слоя. 3⃣Повторять шаг 2, увеличивая счетчик шагов до достижения последнего индекса или пока не закончится очередь. 😎 Решение: package main import "container/list" func minJumps(arr []int) int { n := len(arr) if n 0 { nex := list.New() for e := curs.Front(); e != nil; e = e.Next() { node := e.Value.(int) if node == n-1 { return step } for _, child := range graph[arr[node]] { if !visited[child] { visited[child] = true nex.PushBack(child) } } graph[arr[node]] = nil if node+1 < n && !visited[node+1] { visited[node+1] = true nex.PushBack(node+1) } if node-1 >= 0 && !visited[node-1] { visited[node-1] = true nex.PushBack(node-1) } } curs = nex step++ } return -1 } Ставь 👍 и забирай 📚 Базу знаний
Golang LeetCode

Reseñas de canal Golang LeetCode

Inicia sesión para dejar una reseña

Solo los usuarios registrados pueden compartir su opinión.

Aún no hay reseñas

¡Sé el primero en compartir tu experiencia con este recurso!

Recursos similares

Loading
Cambiar a tema claro
Inicio Catálogo Selecciones Blog Entrar