Here’s the question link :

https://cses.fi/problemset/task/1621

Here’s my solution using unordered maps ( I know that sets can be used here but I want to know what’s wrong with my solution, it’s giving **TLE in few testcases where n=1e5 and answer should be also 1e5** ) :

https://cses.fi/problemset/result/2310768/