Find last element


can you please check the logic and comment out the errors in this code

code is correct
and also passing all testcases

what your doubt in it??

try once again may there were some error previously
now it’s working fine