Блог пользователя msatanzeel

Автор msatanzeel, история, 4 года назад, По-английски

Today there was Google's Kickstart round H and I have a doubt in the question 3 of it, here's that link to the problem , I have solved this using a doubly linked list data structure for efficient replacements and anyone can easily analyze that over all time time complexity is O(n) , here's is the link to my code.Can someone please tell the reason for the TLE over large inputs..

  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится

»
4 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

It can't hurt to try fast IO.

»
4 года назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Have you tried to replace unordered_set with set? unordered_set is unreliable and hackable.

UPD. unordered_map too.

»
4 года назад, скрыть # |
 
Проголосовать: нравится +4 Проголосовать: не нравится

As a start: you're iterating through the entire list every time you check its length.