The removeOperatorsfunction accepts an array of operators to be removed from the operators array. But the problem arises due to issue in the logic where element of the array is being popped off while the loop iterates over the initial length.
As a result, calling removeOperators function will throw Index out of bounds.
Refer to the below code where the length of the operators is stored in a variable named numOperators
Due to the structure of the logic, note how numOperators is the original length of the operators array.
As the remove operators are removed from the array, the length of the operators array will reduce in length, but the logic attempts to iterate the numOperatorswhich is the original length before removing any operators.
Hence, as operators are being removed during the loop, for the second element, the Index out of bounds error will be thrown.
Example: operators = [0,1,2,3,4,5,6]
numOperators = 7
_operators = [2,3,5]
As 2 is pop out of the operators array, array index at 6 will throw index out of bounds array as the length of array is now 6.
Operators cannot be removed by the owner
Manual
In order to fix this issue, initialize the numOperators variable inside the for loop.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.