What is the difference in these submissions ? Codethon 2021

I am getting TLE for the submission of the code given on the left side and the code on the right is being accepted.
Why is this happening? What is the difference between both codes?

Question : Removing Card | Codethon 2021

Actually both the solutions shouldn’t have passed with given constraints :sweat_smile: :sweat_smile: