We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b3ef051 commit dce3870Copy full SHA for dce3870
src/_DataStructures_/Graphs/index.js
src/_DataStructures_/LinkedList/index.js
@@ -151,6 +151,31 @@ class LinkedList {
151
return node;
152
}
153
154
+ filter(value) {
155
+ if (!this.head) {
156
+ return null;
157
+ }
158
+
159
+ if (this.head.data === value) {
160
+ this.head = this.head.next;
161
+ this.size -= 1;
162
163
164
+ let { head } = this;
165
+ let previous = null;
166
167
+ while (head !== null) {
168
+ if (head.data === value) {
169
+ previous.next = head.next;
170
171
172
+ previous = head;
173
+ head = head.next;
174
175
176
+ return this.head;
177
178
179
length() {
180
return this.size;
181
0 commit comments