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.
A little tip for Python 2: after a couple of submissions ending in timeout for the last 3 cases (using merge sort invertion count) I tried to optimize everything and eventually got all correct. A big time saver is using a variable to do the array length comparisons (it got me around 20% performance increase) :
Insertion Sort Advanced Analysis
You are viewing a single comment's thread. Return to all comments →
A little tip for Python 2: after a couple of submissions ending in timeout for the last 3 cases (using merge sort invertion count) I tried to optimize everything and eventually got all correct. A big time saver is using a variable to do the array length comparisons (it got me around 20% performance increase) :
lvar = len(arr)
while i < lvar :
instead of
while i< len(arr)