Ancestry interview question

Two sum problem - leetcode easy Interviwer asked me to do it optimized way only without using two for loops