Please see this code i am not passing thr test cases

Modified Code

Your Mistake

  1. size of array is 10^3 but n can be 10^7 as mention in problem
    but max size of array can be 10^6 in a function
  2. no need to make array just take a variable x for input
    see the reference code

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.