I know I am nitpicking here, but wouldn't it be better to use classic setup where n = 1 and j = n - 1? In this concrete example, because we need to append initial state to the result your approach is working well, but for general case we would have a blank first loop in forloop.
It means that if we directly add it to the result then it will act like a pointer then at the end of sorting all the items in `res` will be sorted since that is the last stage we find it in.
You can implement Insertion Sort yourself here: neetcode.io/problems/insertionSort
A lot more content for neetcode.io on the way 🚀🚀🚀
Exited for this!
I know I am nitpicking here, but wouldn't it be better to use classic setup where n = 1 and j = n - 1? In this concrete example, because we need to append initial state to the result your approach is working well, but for general case we would have a blank first loop in forloop.
What did he mean by "because this is an object and we're continually modifying it"? 6:48
It means that if we directly add it to the result then it will act like a pointer then at the end of sorting all the items in `res` will be sorted since that is the last stage we find it in.
Did you get Nick Fuentes to narrate this?
I think it would be better if the ratio of pro & nrml codes are 6:4 rather than 8:2