&gt;If you are going to test my knowledge, at least ask relevant questions for the role.<p>Even for a front-end developer, I think that algorithms matter, because developers have to understand what they do.<p>And the OP&#x27;s solution in O(N2), as well as the other one with hash maps, seem quite bad (it can be done trivially in O(Nlog(N), and optimized to reach O(N))