ADP interview question

The question was a leetcode easy