We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I dont think that it depends on language its just simply the concept of converting an array in a tree .
Now why i said to convert an array in a tree?
Its just because operations in a tree are much more efficient than on array (specifically in this question).
Now what if you create a tree but that got skewed ?
So try to use the concept of treaps.(Its nothing but using random numbers as priority of array elements to create a tree from an array).
After that is done You can simply do the operations by splitting the tree according to your indexes and then merging them acording to type 1 or type 2.
I think I have tried to simplify the concept.
tell me if you require any further help.
Never tried in Javascript and Python. :P
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Array and simple queries
You are viewing a single comment's thread. Return to all comments →
I dont think that it depends on language its just simply the concept of converting an array in a tree .
Now why i said to convert an array in a tree? Its just because operations in a tree are much more efficient than on array (specifically in this question).
Now what if you create a tree but that got skewed ? So try to use the concept of treaps.(Its nothing but using random numbers as priority of array elements to create a tree from an array).
After that is done You can simply do the operations by splitting the tree according to your indexes and then merging them acording to type 1 or type 2.
I think I have tried to simplify the concept.
tell me if you require any further help.
Never tried in Javascript and Python. :P