DEV Community

[Comment from a deleted post]
Collapse
 
hbgl profile image
hbgl

It's a clean solution but it scales O(n²) which is pretty bad. There is room for improvement.

Collapse
 
shane profile image
Shane McGowan

Any suggestions would be greatly appreciated

Collapse
 
hbgl profile image
hbgl

I don't know the optimal solution but I can give you a hint. You can achieve better scaling by using a Map or by sorting the arrays.