DEV Community

Discussion on: How to Compare Arrays in JavaScript Efficiently

Collapse
 
doabledanny profile image
Danny Adams

Yeah, your solution looks good, best case complexity is 2n.

I could've used one loop to create both frequency counter objects to reduce it down to 2n, but used two loops as I felt it was easier to see what was going on for readers. In hindsight, perhaps I should've just used the one.

Thanks for reading!