Morgan Stanley interview question

1. Solve Leetcode 202. Happy Number