Rakuten interview question

Simple problem that can be solved under 10 minutes