Codeforces and Polygon may be unavailable from December 6, 19:00 (UTC) to December 6, 21:00 (UTC) due to technical maintenance. ×

Need help with understanding an interesting solution for Codechef SORTING

Revision en1, by grey_rabbit, 2020-01-27 17:37:12

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 throughly. So far, I've understood the two functions to 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

Tags #codechef, #segment tree, #quick sort

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English grey_rabbit 2020-01-27 18:38:07 13
en1 English grey_rabbit 2020-01-27 17:37:12 881 Initial revision (published)