MCPcopy Create free account
hub / github.com/careercup/CtCI-6th-Edition-JavaScript / pop

Method pop

chapter02/util/LinkedListX.js:48–65  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

46 }
47
48 pop() {
49 let cur = this.head;
50
51 // only one or no item exists
52 if (!cur) return null;
53 if (!cur.next) {
54 this.head = null;
55 return cur;
56 }
57 // move till the 2nd last
58 while (cur.next.next)
59 cur = cur.next;
60
61 let last = this.tail;
62 this.tail = cur;
63 this.tail.next = null;
64 return last;
65 }
66
67 popFirst() {
68 let first = this.head;

Callers 1

intersectionFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected