Why do we append odd numbers to beginning of array?

Why do we need to check if i is equal to m? And why do we append the odd numbers to the beginning of the array that we currently have?

We do not need to check whether m is equal to i or not. We have fixed this issue in our solution.

We append odd elements at the beginning of the same array because in this way we do not need to create a separate array to store the odd elements of an array. We can make use of the dynamic arrays to write the space-efficient solution. I hope this helps!

Maida Ijaz | Developer Advocate