

The question is in the image attached.
Example:
For queries = ["+4", "+5", "+2". "-4"] and diff = 1, the output should be solution(queries, diff) = [0, 1, 1, 0].
First, process queries[0] = "+4" and add 4 to numbers, resulting in nubers = [4]. There are no pairs with diff = 1, so append 0 to the output.
Next, process queries[i] = "+5" and add 5 to numbers, resulting in numbers = [4, 5]. The numbers 4 and 5 have difference diff = 1, so append 1 to the output.
Now, process queries[2] = "+2" and add 2 to numbers, resulting in numbers = [4, 5, 2]. The number of pairs with difference diff = 1 remains the same, so append 1 to the output.
Process queries[3] = "-4" and remove an instance of number 4 resulting in numbers = [5, 2]. There are no pairs with difference diff = 1, so append 0 to the output.
The final output is [0, 1, 1, 0].
Guaranteed constraints: 1 <= diff <= 10^9.
Please let me know if anyone can solve.