📌📌 Simple to understand || For Beginners || 91% faster 🐍
IDEA:\n Separate all even and odd numbers Once.\n Then now replace original arr with alternate even and odd numbers.\n Here flag denotes you are at even index.\
## IDEA:\n* Separate all even and odd numbers Once.\n* Then now replace original arr with alternate even and odd numbers.\n* Here flag denotes you are at even index.\n\n**For Biginners:**\n\'\'\'\n\n\tclass Solution:\n    def sortArrayByParityII(self, nums: List[int]) -> List[int]:\n        \n        odd,even = [],[]\n        for n in nums:\n            if n%2: odd.append(n)\n            else: even.append(n)\n        \n        o,e = 0,0\n        for i in range(len(nums)):\n            if i%2==0:\n                nums[i]=even[e]\n                e+=1\n            else:\n                nums[i]=odd[o]\n                o+=1\n        \n        return nums\n\n**Most Efficient:**\n\'\'\'\n\t\n\tclass Solution:\n    def sortArrayByParityII(self, nums: List[int]) -> List[int]:\n        \n        e = 0                            #even_index\n        o = 1                            #odd_index\n        \n        while e<len(nums) and o<len(nums):\n            if nums[e]%2==0:\n                e+=2\n            else:\n                if nums[o]%2!=0:\n                    o+=2\n                else:\n                    nums[e],nums[o] = nums[o],nums[e]\n                    e+=2\n                    o+=2\n                                \n        return num\n\n### Thanks and Upvote If you got any help !!\uD83E\uDD1E
['Python', 'Python3']