Is there any way to optimise the code of insertion sort?

I was writing a code of insertion sort in an online judge and when I submit it , compiler told me to optimise the code . How can I do it?


<img src="https://minio.codingblocks.com/amoeba/cca00df9-f16a-4398-8864-4f5de81c6744.png

Hey @sarthak_singhal you are doing insertion sort in sorting 0,1 & 2 in linear time question. So there are 2 things i want to tell first that insertion sort works in O(N*N) time ehich you code is doing and that is absolutely fine cause there’s no way to optimize it further.
Whereas as far as this problem is concerned. It’s in your course too where they have taught you to sort this in O(N) time complexity. So i would suggest you to do that algorithm in this question instead of using insertion sort. If you have any other doubt related to this, feel free to ask.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.