Practice Movement of Robots
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Robot i begins at nums[i] and moves at one unit per second in direction s[i], L for left or R for right. When robots meet, they immediately reverse directions without pausing, including collisions between integer seconds. Return the sum of distances over all unordered robot pairs after d seconds, modulo 10^9 + 7.
Source: Movement of Robots on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
nums = [-2,0,2], s = "RLL", d = 3
Output
8
# Example 2
Input
nums = [1,0], s = "RL", d = 2
Output
5
Constraints
2 <= nums.length <= 10^5
-2 * 10^9 <= nums[i] <= 2 * 10^9
0 <= d <= 10^9
nums.length == s.length
s consists of 'L' and 'R' only
nums[i] will be unique.
Related LeetCode Problems
Practice more problems similar to Movement of Robots.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.