How to solve "Insertion Sort Advanced Analysis" on HackerRank

T he challenge is essentially to figure out how inefficient it would be to insertion sort an array without actually doing an insertion sort. We can’t get around actually sorting the array, so what we need is a sort method that has equivalent behavior to an insertion sort, but is much more efficient. The simplest answer is a binary search tree. A binary search tree remains sorted after every…