Regarding the time complexity for AtCoder Beginner Contest 201 Problem B

Правка en1, от Girus, 2021-06-04 07:36:23

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!

Теги #time complexity, #atcoder

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский Girus 2021-06-04 07:36:23 934 Initial revision (published)