File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
Data-Structures/Linked-List Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ class LinkedList {
44
44
}
45
45
46
46
// Returns the tail
47
- tail ( ) {
47
+ tail ( ) {
48
48
return this . tailNode ?. data || null
49
49
}
50
50
@@ -68,7 +68,7 @@ class LinkedList {
68
68
}
69
69
70
70
// add a node at first it to linklist
71
- addFirst ( element ) {
71
+ addFirst ( element ) {
72
72
const node = new Node ( element )
73
73
// Check if its the first element
74
74
if ( this . headNode === null ) {
@@ -130,7 +130,7 @@ class LinkedList {
130
130
if ( this . tailNode . data === element ) {
131
131
return this . removeLast ( )
132
132
}
133
- // Check whch node is the node to remove
133
+ // Check which node is the node to remove
134
134
while ( currentNode . next ) {
135
135
if ( currentNode . next . data === element ) {
136
136
removedNode = currentNode . next
@@ -144,7 +144,7 @@ class LinkedList {
144
144
}
145
145
146
146
// Returns the index of the element passed as param otherwise -1
147
- indexOf ( element ) {
147
+ indexOf ( element ) {
148
148
if ( this . isEmpty ( ) ) return - 1
149
149
let { currentNode, currentIndex } = this . initiateNodeAndIndex ( )
150
150
while ( currentNode ) {
@@ -258,7 +258,7 @@ class LinkedList {
258
258
}
259
259
current . next = this . headNode
260
260
tail = current
261
- k = k % count
261
+ k %= count
262
262
while ( count - k > 0 ) {
263
263
tail = tail . next
264
264
count --
You can’t perform that action at this time.
0 commit comments