nairnikhil848 / game-of-robots Goto Github PK
View Code? Open in Web Editor NEWAll submissions for this problem are available.You've built some robots and placed them on an one dimensional grid with n cells. Their arrangement is given by a string s of length n. Each character of the string is either '.' or a digit in the range '0' to '9'. A '.' represents that there is no robot at that cell initially. A digit represents a robot initially in that cell. Specifically, the digit x denotes that the range of the robot is from x cells to the left of its starting point to x cells to the right of its starting point. For example, suppose the 7th character of the string is 3, then that means that there is a robot starting from the 7th cell, and its range is from the 4th cell (7 - 3 = 4) to the 10th cell (7 + 3 = 10) (both end points inclusive). The robots can move only within their range, and even if their range allows it, they cannot move out of the grid.