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
Consider using the standard .values instead of the custom .toArray. Besides, I'd also suggest to use Set's methods as much as possible since it is implemented as a hashset, which is very efficient, instead of relying on Array's methods which usually take at least linear time.
For example, .intersection could be implemented along the following lines
intersection(s1, s2) {
s3 = new Set();
s1.forEach(value => {
if (s2.has(value)) {
s3.add(value);
}
});
return s3;
}
The text was updated successfully, but these errors were encountered:
Consider using the standard
.values
instead of the custom.toArray
. Besides, I'd also suggest to useSet
's methods as much as possible since it is implemented as a hashset, which is very efficient, instead of relying onArray
's methods which usually take at least linear time.For example,
.intersection
could be implemented along the following linesThe text was updated successfully, but these errors were encountered: