mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-12-25 22:46:20 +08:00
Twice defined (#124)
* Twice defined Parameter 'deletedTail' were defined twice. * Update LinkedList.js * Update LinkedList.js
This commit is contained in:
parent
6e897a0a7a
commit
5105898aa7
@ -127,18 +127,14 @@ export default class LinkedList {
|
||||
* @return {LinkedListNode}
|
||||
*/
|
||||
deleteTail() {
|
||||
const deletedTail = this.tail;
|
||||
if (this.head === this.tail) {
|
||||
// There is only one node in linked list.
|
||||
const deletedTail = this.tail;
|
||||
this.head = null;
|
||||
this.tail = null;
|
||||
|
||||
return deletedTail;
|
||||
}
|
||||
|
||||
// If there are many nodes in linked list...
|
||||
const deletedTail = this.tail;
|
||||
|
||||
// Rewind to the last node and delete "next" link for the node before the last one.
|
||||
let currentNode = this.head;
|
||||
while (currentNode.next) {
|
||||
|
Loading…
Reference in New Issue
Block a user