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

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

Hello everyone. This is a CSES problem: Subarray Distinct Values very simple and straightforward 2 pointer approach. My time complexity is O(n) visiting every array element almost twice. But I am getting TLE. Why.

My code: My Code on CSES

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

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

You can get ac by using map instead of unordered_map, nlog time complexity will work here. It is not necessary that every operation of an unordered_map will be of O(1) complexity. See this post by neal https://codeforces.com/blog/entry/62393 , you can use custom_hash in your unordered_map by neal to get ac.