MCPcopy Create free account
hub / github.com/neetcode-gh/leetcode / addAtTail

Method addAtTail

javascript/0707-design-linked-list.js:35–44  ·  view source on GitHub ↗
(val)

Source from the content-addressed store, hash-verified

33 }
34
35 addAtTail(val) {
36 if (this.head === null) {
37 this.head = new Node(val);
38 this.tail = this.head;
39 } else {
40 this.tail.next = new Node(val);
41 this.tail.next.prev = this.tail;
42 this.tail = this.tail.next;
43 }
44 }
45
46 addAtIndex(index, val) {
47 if (index === 0) this.addAtHead(val);

Callers 1

addAtIndexMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected