NOOB CODE : EASY TO UNDERSTAND + VERY EFFICIENT
\n# Intuition\nIn a new list insert the elements at the end if its odd else at the beginning \n# Approach\nInitialize an empty list l1 to store the sorted integ
![Screenshot 2023-09-28 110254.png](https://assets.leetcode.com/users/images/0f7d8459-8ab3-42fb-a3a8-1541bf485f53_1695879188.7091277.png)\n# Intuition\nIn a new list insert the elements at the end if its odd else at the beginning \n# Approach\nInitialize an empty list l1 to store the sorted integers.\n\nLoop through each element i in the input list nums.\n\nCheck if i is even by using the condition (i % 2 == 0). If it\'s even, append it to the l1 list.\n\nAfter the first loop, l1 will contain all the even integers from the input list.\n\nNow, loop through the input list nums again.\n\nCheck if i is odd by using the condition (i % 2 != 0). If it\'s odd, append it to the l1 list.\n\nAfter the second loop, l1 will contain all the odd integers from the input list.\n\nFinally, return the sorted list l1, where even integers appear before odd integers.\n\n# Complexity\n- Time complexity: ***O(n)***\n\n- Space complexity: ***O(n)***\n\n# Code\n```\nclass Solution:\n    def sortArrayByParity(self, nums: List[int]) -> List[int]:\n        l1=[]\n        for i in nums:\n            if (i%2==0):\n                l1.append(i)\n        for i in nums:\n            if (i%2!=0):\n                l1.append(i)\n        return(l1)\n```
['Python3']