IXL Learning interview question

Using data structure such as set and dictionary to solve the problem.