Solve word path in grid and trapped water | Bloomberg Interview Question