Komprise interview question

Water trapping problem in coding round .