Andal Software interview question

Was asked to code a leetcode problem