Rakuten interview question

Solve a given coding question