I got this question in an interview. Can anyone help me with the best approach to solve this question?