Rakuten Interview Question

1. Simple String and loops. 2. Some greedy algorithm problem that is more adhoc-ish. I got the solution partly right, and realized my mistake thereafter but has no time left.