From f4a2006e60aebee626c6945726e44991c79bd951 Mon Sep 17 00:00:00 2001 From: vrutikjadav Date: Tue, 23 Jan 2024 12:06:36 +0530 Subject: [PATCH] #1020 updating insert at Head part --- src/data-structures/linked-list/LinkedList.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/data-structures/linked-list/LinkedList.js b/src/data-structures/linked-list/LinkedList.js index ba7d0e3e..4c8d32b2 100644 --- a/src/data-structures/linked-list/LinkedList.js +++ b/src/data-structures/linked-list/LinkedList.js @@ -80,8 +80,10 @@ export default class LinkedList { this.tail.next = newNode; this.tail = newNode; } else { - this.head = newNode; - this.tail = newNode; + // this.head = newNode; + // this.tail = newNode; + newNode.next = this.head; + newNode = this.head; } } }