Help Needed in REBXOR

Can someone please point out the reason for TLE in this solution for the Problem
I have almost tried to implement the editorial solution based on Tries.