I recently solved a question where my algo has complexity of O(N).

Surprisingly, on constraint where N<=1000, Solution takes 0.97 seconds ; but on constraint where N<=100000 ;

it takes 0.00 seconds **(C++ Solution)**. Why is that happening…??? And even why at a constraint of N<=1000 ; solution is taking nearly 1 second time even in C++ ?

This is the link to My Solution for this problem

I have recently began to upsolve problems in C++ and am new to language… Please help…