There are
n1-indexed robots, each having a position on a line, health, and movement direction.You are given 0-indexed integer arrays
positions,healths, and a stringdirections(directions[i]is either ‘L’ for left or ‘R’ for right). All integers inpositionsare unique.All robots start moving on the line simultaneously at the same speed in their given directions. If two robots ever share the same position while moving, they will collide.
If two robots collide, the robot with lower health is removed from the line, and the health of the other robot decreases by one. The surviving robot continues in the same direction it was going. If both robots have the same health, they are both removed from the line.
Your task is to determine the health of the robots that survive the collisions, in the same order that the robots were given, i.e. final heath of robot 1 (if survived), final health of robot 2 (if survived), and so on. If there are no survivors, return an empty array.
Return an array containing the health of the remaining robots (in the order they were given in the input), after no further collisions can occur.
Note: The positions may be unsorted.
2750. Ways to Split Array Into Good Subarrays
You are given a binary array
nums.A subarray of an array is good if it contains exactly one element with the value
1.Return an integer denoting the number of ways to split the array
numsinto good subarrays. As the number may be too large, return it modulo109 + 7.A subarray is a contiguous non-empty sequence of elements within an array.
2749. Minimum Operations to Make the Integer Zero
You are given two integers
num1andnum2.In one operation, you can choose integer
iin the range[0, 60]and subtract2i + num2fromnum1.Return the integer denoting the minimum number of operations needed to make
num1equal to0.If it is impossible to make
num1equal to0, return-1.
2748. Number of Beautiful Pairs
You are given a 0-indexed integer array
nums. A pair of indicesi,jwhere0 <= i < j < nums.lengthis called beautiful if the first digit ofnums[i]and the last digit ofnums[j]are coprime.Return the total number of beautiful pairs in
nums.Two integers
xandyare coprime if there is no integer greater than 1 that divides both of them. In other words,xandyare coprime ifgcd(x, y) == 1, wheregcd(x, y)is the greatest common divisor ofxandy.
2747. Count Zero Request Servers
You are given an integer
ndenoting the total number of servers and a 2D 0-indexed integer arraylogs, wherelogs[i] = [server_id, time]denotes that the server with idserver_idreceived a request at timetime.You are also given an integer
xand a 0-indexed integer arrayqueries.Return a 0-indexed integer array
arrof lengthqueries.lengthwherearr[i]represents the number of servers that did not receive any requests during the time interval[queries[i] - x, queries[i]].Note that the time intervals are inclusive.