Magical string 1(stuck)

sir please help me to solve this problem i have explained my logic in the comments but only sample test cases are passing i cant think of anything else can u please tell me what am i not doing wrong in this approach

in loop for map it is going from 0 to 26