Pls check the code its giving TLE

hello @sneha23
pls check ur updated code here->