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

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

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
  • Проголосовать: не нравится