Time error in my code

i am getting time error on my code

hi @asitshastri
your approach to solve this problem is very naive ,
try to go for some smarter approach to reduce the complexity of code
present complexity : O(n^2)
try another optimised approach