https://gateoverflow.in/86224/gate1990-13a
for tym complexity ..is it like …..n times we need to search position so O(nlogn)
n insertion so O(n)
and only two rotation so O(logn)...because i m not rotating for each iteration just doing at last
so overall O(nlogn)...please look...