We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3be6003 commit 62f19bdCopy full SHA for 62f19bd
03-DataStructures/LinkedList.js
@@ -0,0 +1,32 @@
1
+class Node {
2
+ constructor(value) {
3
+ this.value = value;
4
+ this.next = null;
5
+ }
6
7
+
8
+ class LinkedList {
9
+ constructor() {
10
+ this.head = null;
11
+ this.tail = null;
12
+ this.length = 0;
13
14
15
+ append(value) {
16
+ const newNode = new Node(value);
17
+ if (!this.head) {
18
+ this.head = newNode;
19
+ this.tail = newNode;
20
+ } else {
21
+ this.tail.next = newNode;
22
23
24
+ this.length++;
25
26
27
28
+ const list = new LinkedList();
29
+ list.append(1);
30
+ list.append(2);
31
+ list.append(3);
32
0 commit comments