Logo
TGCATALOG
Catalog Collections Blog
Java | LeetCode

Java | LeetCode

LeetCode tasks and solutions in Java.

No ratings
283
30.11.2026
283
30.11.2026
No ratings
283
30.11.2026
Safe redirect via bot
О канале

LeetCode tasks and solutions in Java.

Подписчиков —
Тематика Technology
Ссылка @easy_java_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 task solutions in Java with emphasis on clean code and optimization. Topics: arrays, trees, graphs, dynamic programming. Ideal for technical preparation.

Latest posts

Java | LeetCode
Java | 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⃣Операции удаления: Реализуйте методы удаления элементов из передней и задней частей очереди с учетом кольцевой структуры и методы для получения переднего и заднего элементов очереди. 😎 Решение: public class MyCircularDeque { private int[] deque; private int front; private int rear; private int size; private int capacity; public MyCircularDeque(int k) { this.capacity = k; this.deque = new int[k]; this.front = 0; this.rear = 0; this.size = 0; } public boolean insertFront(int value) { if (isFull()) return false; front = (front - 1 + capacity) % capacity; deque[front] = value; size++; return true; } public boolean insertLast(int value) { if (isFull()) return false; deque[rear] = value; rear = (rear + 1) % capacity; size++; return true; } public boolean deleteFront() { if (isEmpty()) return false; front = (front + 1) % capacity; size--; return true; } public boolean deleteLast() { if (isEmpty()) return false; rear = (rear - 1 + capacity) % capacity; size--; return true; } public int getFront() { if (isEmpty()) return -1; return deque[front]; } public int getRear() { if (isEmpty()) return -1; return deque[(rear - 1 + capacity) % capacity]; } public boolean isEmpty() { return size == 0; } public boolean isFull() { return size == capacity; } } Ставь 👍 и забирай 📚 Базу знаний
Java | LeetCode
FAQ

Open Java | 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 Java | LeetCode directly in Telegram unless the resource description says otherwise.

Access depends on the resource. Check the current information in Telegram after opening Java | LeetCode.

The exact features depend on the resource. Open Java | LeetCode to see its current functions, content and access conditions.

Reviews for channel Java | 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