You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if(Number.isNaN(value)){thrownewError(`Comparator should evaluate to a number. Got ${value} when comparing ${this.array[i1]} with ${this.array[i2]}`);}
14
+
returnvalue;
15
+
};
12
16
}
13
17
14
18
/**
@@ -34,8 +38,8 @@ class Heap {
34
38
* @runtime O(log n)
35
39
*/
36
40
remove(index=0){
37
-
if(!this.size())returnnull;
38
-
this.swap(index,this.size()-1);// swap with last
41
+
if(!this.size)returnnull;
42
+
this.swap(index,this.size-1);// swap with last
39
43
constvalue=this.array.pop();// remove element
40
44
this.bubbleDown(index);
41
45
returnvalue;
@@ -45,7 +49,7 @@ class Heap {
45
49
* Returns the number of elements in this collection.
0 commit comments