Morgan Stanley interview question

2-sum problem with a few variations