Hi, there! Thank you for the explanation, but in the first example nums = [1, 0, 0] and queries = [[0,2]] it's not clear for me why we're not modifying the number zero. Could you please explain this? Thanks a lot!
Because at the end, we are looking for our array to be all 0's example - [0,0,0,0] at the end. If you decrement more than 0, you'll get a negative number. So subtracting further after seeing a 0 will ruin the array.
What @dThapa966 said is correct. We want to make all the elements equal 0. For each query, we only need to choose a subset of elements in the range. This means that we can choose not to decrement any elements which are already 0
Hi, there!
Thank you for the explanation, but in the first example nums = [1, 0, 0] and queries = [[0,2]] it's not clear for me why we're not modifying the number zero. Could you please explain this?
Thanks a lot!
Because at the end, we are looking for our array to be all 0's example - [0,0,0,0] at the end. If you decrement more than 0, you'll get a negative number. So subtracting further after seeing a 0 will ruin the array.
What @dThapa966 said is correct. We want to make all the elements equal 0. For each query, we only need to choose a subset of elements in the range. This means that we can choose not to decrement any elements which are already 0