Adobe interview question

Resolve a leetcode problem on HackerRank