FDM Group interview question

Q: Leetcode style question (easy leetcode)