Robots occupy distinct positions on a number line. Arrays positions and healths and string directions describe them in their original input order. Each robot moves at the same speed, left for L or right for R.
When two robots meet, the one with less health disappears and the other loses one health point. If their healths are equal, both disappear. A surviving robot continues in its original direction.
Return the final healths of all surviving robots in their original input order, after every possible collision. Return an empty array if none survive. The positions are not necessarily sorted.
The number inside each robot is its health; the number underneath is its position, and the arrow gives its direction.
Example 1:
Input: positions=[8,2,5]
healths=[4,7,3]
directions="RRR"
Output: [4,7,3]Explanation: All robots move right at the same speed, so they never meet. Their healths stay [4,7,3], in input order rather than position order.
Example 2:
Input: positions=[1,4,8]
healths=[3,5,2]
directions="RLL"
Output: [4,2]Explanation: The robot at 1 meets the robot at 4. Health 3 loses to health 5, leaving the second robot with health 4. Both remaining robots move left and never collide, so their healths in input order are [4,2].
Example 3:
Input: positions=[7,2]
healths=[6,6]
directions="LR"
Output: []Explanation: The robot at 2 moves right and the robot at 7 moves left. They meet with equal health, so both disappear.
Constraints:
1 <= positions.length == healths.length == directions.length <= 10^51 <= positions[i], healths[i] <= 10^9- All positions are distinct.
- Each direction is
LorR.