mirror of
https://github.com/krahets/hello-algo.git
synced 2026-10-22 14:05:19 +08:00
fix: sync array, deque, and printing fixes across translations (#1973)
Synchronize the fixes from #1936, #1824, and #1961 across translated editions and normalize C# and Dart formatting. Move Java CI to Ubuntu 24.04 so its Java 11/17 checks can run.
This commit is contained in:
@@ -76,25 +76,27 @@ class LinkedListDeque {
|
||||
if (isEmpty())
|
||||
throw new IndexOutOfBoundsException();
|
||||
int val;
|
||||
// When the deque has one element, front and rear point to the same node
|
||||
if (queSize == 1) {
|
||||
val = front.val;
|
||||
front = null;
|
||||
rear = null;
|
||||
}
|
||||
// Temporarily store head node value
|
||||
if (isFront) {
|
||||
else if (isFront) {
|
||||
val = front.val; // Delete head node
|
||||
// Delete head node
|
||||
ListNode fNext = front.next;
|
||||
if (fNext != null) {
|
||||
fNext.prev = null;
|
||||
front.next = null;
|
||||
}
|
||||
fNext.prev = null;
|
||||
front.next = null;
|
||||
front = fNext; // Update head node
|
||||
// Temporarily store tail node value
|
||||
} else {
|
||||
val = rear.val; // Delete tail node
|
||||
// Update tail node
|
||||
ListNode rPrev = rear.prev;
|
||||
if (rPrev != null) {
|
||||
rPrev.next = null;
|
||||
rear.prev = null;
|
||||
}
|
||||
rPrev.next = null;
|
||||
rear.prev = null;
|
||||
rear = rPrev; // Update tail node
|
||||
}
|
||||
queSize--; // Update queue length
|
||||
|
||||
Reference in New Issue
Block a user