Rakuten interview question

Typical leetcode easy to medium for technical