Morgan Stanley interview question

One Leetcode Question which was a medium Leetcode.