I have seen the Input/Output/Explanation format in some test site before, and a lot of their questions were ambiguous or badly stated.
This one looks simple: just explain to yourself how their examples work, then explain that (in Java) to your Laptop.
Performance should not be an issue with an array size of 105, but these sites will time your code to stop you using brute-force code, and make you think. Typically, you need to get below 0.5 seconds.
I get a bad feeling that you have mistyped the Constraints: are you sure it is not:
Constraints: 1 ≤ arr.size() ≤ 10e+5 1 ≤ arr[i] ≤ 10e+4, so 100,000 array elements, all in the range 1 to 10,000?
View all comments
1
u/Paul_Pedant Sep 06 '25
What have you got, where are you stuck?
I have seen the Input/Output/Explanation format in some test site before, and a lot of their questions were ambiguous or badly stated.
This one looks simple: just explain to yourself how their examples work, then explain that (in Java) to your Laptop.
Performance should not be an issue with an array size of 105, but these sites will time your code to stop you using brute-force code, and make you think. Typically, you need to get below 0.5 seconds.
I get a bad feeling that you have mistyped the Constraints: are you sure it is not:
Constraints: 1 ≤ arr.size() ≤ 10e+5 1 ≤ arr[i] ≤ 10e+4, so 100,000 array elements, all in the range 1 to 10,000?