Girus's blog

By Girus, history, 19 months ago, In English

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 ?

Full text and comments »

  • Vote: I like it
  • -5
  • Vote: I do not like it

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!

Full text and comments »

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