mirror of
https://github.com/krahets/hello-algo.git
synced 2026-10-22 05:55:18 +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:
@@ -67,13 +67,18 @@ class LinkedListDeque {
|
||||
return null;
|
||||
}
|
||||
const value = this.#rear.val; // Store tail node value
|
||||
// When the deque has one element, front and rear point to the same node
|
||||
if (this.#queSize === 1) {
|
||||
this.#front = null;
|
||||
this.#rear = null;
|
||||
}
|
||||
// Update tail node
|
||||
let temp = this.#rear.prev;
|
||||
if (temp !== null) {
|
||||
else {
|
||||
let temp = this.#rear.prev;
|
||||
temp.next = null;
|
||||
this.#rear.prev = null;
|
||||
this.#rear = temp; // Update tail node
|
||||
}
|
||||
this.#rear = temp; // Update tail node
|
||||
this.#queSize--;
|
||||
return value;
|
||||
}
|
||||
@@ -83,14 +88,19 @@ class LinkedListDeque {
|
||||
if (this.#queSize === 0) {
|
||||
return null;
|
||||
}
|
||||
const value = this.#front.val; // Store tail node value
|
||||
const value = this.#front.val; // Store the head node value
|
||||
// When the deque has one element, front and rear point to the same node
|
||||
if (this.#queSize === 1) {
|
||||
this.#front = null;
|
||||
this.#rear = null;
|
||||
}
|
||||
// Delete head node
|
||||
let temp = this.#front.next;
|
||||
if (temp !== null) {
|
||||
else {
|
||||
let temp = this.#front.next;
|
||||
temp.prev = null;
|
||||
this.#front.next = null;
|
||||
this.#front = temp; // Update head node
|
||||
}
|
||||
this.#front = temp; // Update head node
|
||||
this.#queSize--;
|
||||
return value;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user