What is wrong in this code? biotonic subsequence

when i submitted the same code on hacker blocks it was right but when i try to submit in challenges it shows something wrong

khushi see the constraint n can be upto 1000000 and u r using an o(n^2) approach so it will not work
try to optimize ur code int 0(n) or o(nlogn)