Kivi Capital interview question

Based on the previous work