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

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

Good evening all,

I am reaching out, as I had some questions about the editorial for ABC 277 problem C. The editorial for ABC 277 C — Ladder Takahashi states that the time complexity for the aforementioned problem is O(N * log (N)).

  1. Where is this logarithmic factor coming from ? Is this from the set and map data structures which take logarithmic time for insertion and search operation ?
  2. Would the time complexity reduce to O(N) on average if we were to use an unordered_map or unordered_set ?

Полный текст и комментарии »

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

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

In the editorial for AtCoder Beginner Contest 201 Problem B Do you know the second highest mountain?, it states that the time complexity for the two approaches via sorting and a single traversal are O(M*log(N)) and O(M), where M is the sum of lengths of Si.

I am slightly confused about how the author of the editorial reached that conclusion.
Should the time complexity for the two approaches be O(N * log(N)) and O(N) instead, as the first_type of the pair<int, string> is an integer and hence would take only a constant time for comparison and access?

I have also included my O(N) solution to this problem. Please correct me if I am wrong.

Thank you!

Полный текст и комментарии »

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