There are positions, healths, and a string directions, where positions[i], healths[i], and directions[i] represent the position, health, and movement direction of the
All robots start moving simultaneously at the same speed. A robot moves to the left if its direction is 'L' and to the right if its direction is 'R'.
When two robots moving towards each other collide:
The robot with lower health is destroyed, and the health of the surviving robot decreases by
If both robots have the exact same health, both are destroyed.
Robots moving in the same direction or moving away from each other never collide.
Return an array containing the health of the surviving robots, ordered as they appeared in the initial input.
Constraints:
positions.length healths.length directions.length
positions[i], healths[i]
directions[i] 'L' or directions[i] 'R'
All values in positions are distinct
There are positions, healths, and a string directions, where positions[i], healths[i], and directions[i] represent the position, health, and movement direction of the
All robots start moving simultaneously at the same speed. A robot moves to the left if its direction is 'L' and to the right if its direction is 'R'.
When two robots moving towards each other collide:
The robot with lower health is destroyed, and the health of the surviving robot decreases by
If both robots have the exact same health, both are destroyed.
Robots moving in the same direction or moving away from each other never collide.
Return an array containing the health of the surviving robots, ordered as they appeared in the initial input.
Constraints:
positions.length healths.length directions.length
positions[i], healths[i]
directions[i] 'L' or directions[i] 'R'
All values in positions are distinct