How to Solve Two Sum in JavaScript
Solve the classic interview problem in linear time without sorting.
Published in
7 min readNov 24, 2019
Two Sum — It’s possibly one of the most prolific algorithm questions in existence, and as such, should be practiced extensively.
Even though it is a common question, there are many variants to this problem that could trip up a developer in an interview.
One constraint that could be used in an interview would be to disallow sorting the input array. This constraint is a great way to assess if a candidate has a…