Two Sum - Part 2 - Interview Question
Prerequisite:Basic HashMap, Array, Loop, and Big O knowledge.
This is Part 2 of a series.
( Problem Recap )
Given an integer array and target, return the indices of the two numbers that add up to the target number.
Requirements:You may not use the same element twice.
( Improving our answer )
Our Brute Force, nested loop answer, had a time complexity of
We can improve our time complexity if we get rid of the nested loop.