SabPaisa interview question

Rainwater trapping problem. String rotation.