ishu9bansal / ideone

useful pieces of codes
1 stars 1 forks source link

Implement Fast Insert at random index #6

Open ishu9bansal opened 4 years ago

ishu9bansal commented 4 years ago

Implementation and use case https://leetcode.com/submissions/detail/350265425/

ishu9bansal commented 4 years ago

It's inefficient when inserts are not so random. To improve on that, we can restructure the underlying tree, making it balanced, which can be done in O(n) time.