Skip to content

Commit

Permalink
Twice defined (trekhleb#124)
Browse files Browse the repository at this point in the history
* Twice defined

Parameter 'deletedTail' were defined twice.

* Update LinkedList.js

* Update LinkedList.js
  • Loading branch information
seIncorp authored and trekhleb committed Jul 30, 2018
1 parent 6e897a0 commit 5105898
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/data-structures/linked-list/LinkedList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 5105898

Please sign in to comment.