Sunbit interview question

Write a solution for a task from leetcode.