DEV Community

Discussion on: Two Sum Solution in JavaScript

Collapse
 
abmsourav profile image
Keramot UL Islam • Edited
  1. In the second function all happening in one loop, so time complexity is O(n). indexOf is an API method. It's way faster than a loop.
  2. Please run the first example and check the output.