Microsoft interview question

2 sum (brute + optimal approach)