Playlist Problem CSES

Problem link:
Code link:

I am using 2 pointers + sliding window technique. But I am getting a TLE in some cases. Can someone pls tell me what I am doing wrong? Or is this approach inefficient.

Approach I used

Keep on increasing window length, while we have string a with unique characters.
As soon as we find a duplicate, we delete from the array till the string does not contain duplicate