Playlist Problem CSES

Problem link: https://cses.fi/problemset/task/1141
Code link: https://cses.fi/paste/408cea2327e7ddb2130854/

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