Please subscribe to the official Codeforces channel in Telegram via the link ×

grey_rabbit's blog

By grey_rabbit, history, 4 years ago, In English

Problem statement: SORTING

A common solution for this problem is to use Persistent Segment tree and Binary Search, which runs in O(n log n). However, as I was reading the editorial for some extra insights, I encountered a solution that doesn't involve any advanced data structure but a Doubly Linked List, and (according to the author of the solution) runs in O(n). I spent an hour examining the solution but still haven't managed to understand it thoroughly. So far, I've understood the two functions to create and delete elements from the linked list, but couldn't how T[b] and T[e] work. Can someone please help me out ?

Link to the solution

Full text and comments »

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