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
🔒Открыть пост
и посмотреть медиа
Задача: 641. Design Circular Deque Сложность: medium Разработайте свою реализацию круговой двусторонней очереди (deque). Реализуйте класс MyCircularDeque: MyCircularDeque(int k) Инициализирует deque с максимальным размером k. boolean insertFront() Добавляет элемент в переднюю часть Deque. Возвращает true, если операция прошла успешно, или false в противном случае. boolean insertLast() Добавляет элемент в заднюю часть Deque. Возвращает true, если операция выполнена успешно, или false в противном случае. boolean deleteFront() Удаляет элемент из передней части Deque. Возвращает true, если операция прошла успешно, или false в противном случае. boolean deleteLast() Удаляет элемент из задней части Deque. Возвращает true, если операция прошла успешно, или false в противном случае. int getFront() Возвращает передний элемент из Deque. Возвращает -1, если Deque пуст. int getRear() Возвращает последний элемент из Deque. Возвращает -1, если Deque пуст. boolean isEmpty() Возвращает true, если Deque пуст, или false в противном случае. boolean isFull() Возвращает true, если Deque полон, или false в противном случае. Пример: Input ["MyCircularDeque", "insertLast", "insertLast", "insertFront", "insertFront", "getRear", "isFull", "deleteLast", "insertFront", "getFront"] [[3], [1], [2], [3], [4], [], [], [], [4], []] Output [null, true, true, true, false, 2, true, true, true, 4] 👨💻 Алгоритм: 1⃣Инициализация и проверка состояний Реализуйте конструктор для инициализации кольцевой двусторонней очереди заданного размера и методы для проверки пустоты и полноты очереди. 2⃣Операции вставки Реализуйте методы вставки элементов в переднюю и заднюю части очереди с учетом кольцевой структуры. 3⃣Операции удаления Реализуйте методы удаления элементов из передней и задней частей очереди с учетом кольцевой структуры и методы для получения переднего и заднего элементов очереди. 😎 Решение: package main type MyCircularDeque struct { deque []int front int rear int size int capacity int } func Constructor(k int) MyCircularDeque { return MyCircularDeque{ deque: make([]int, k), front: 0, rear: 0, size: 0, capacity: k, } } func (this *MyCircularDeque) InsertFront(value int) bool { if this.IsFull() { return false } this.front = (this.front - 1 + this.capacity) % this.capacity this.deque[this.front] = value this.size++ return true } func (this *MyCircularDeque) InsertLast(value int) bool { if this.IsFull() { return false } this.deque[this.rear] = value this.rear = (this.rear + 1) % this.capacity this.size++ return true } func (this *MyCircularDeque) DeleteFront() bool { if this.IsEmpty() { return false } this.front = (this.front + 1) % this.capacity this.size-- return true } func (this *MyCircularDeque) DeleteLast() bool { if this.IsEmpty() { return false } this.rear = (this.rear - 1 + this.capacity) % this.capacity this.size-- return true } func (this *MyCircularDeque) GetFront() int { if this.IsEmpty() { return -1 } return this.deque[this.front] } func (this *MyCircularDeque) GetRear() int { if this.IsEmpty() { return -1 } return this.deque[(this.rear-1+this.capacity)%this.capacity] } func (this *MyCircularDeque) IsEmpty() bool { return this.size == 0 } func (this *MyCircularDeque) IsFull() bool { return this.size == this.capacity } Ставь 👍 и забирай 📚 Базу знаний
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