SabPaisa Interview Question

Rainwater trapping problem. String rotation.