Canva interview question

1 Leet code medium question.