Girus's blog

By Girus, history, 3 years ago, In English

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!

  • Vote: I like it
  • +10
  • Vote: I do not like it