Easy and beginner friendly solution in C++
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n       vector<int> sortArrayByParity(std::vector<int>& nums) {\n    int j = 0; // Initialize a pointer to track the position for even integers\n\n    // Iterate through the vector\n    for (int i = 0; i < nums.size(); i++) {\n        // If the current element is even, swap it with the element at index j\n        if (nums[i] % 2 == 0) {\n            std::swap(nums[i], nums[j]);\n            j++; // Increment the pointer to the next position for even integers\n        }\n    }\n\n    // The vector is now rearranged with even integers at the beginning and odd integers at the end\n    return nums;\n}\n\n};\n```\n# Another Solution\n```\nclass Solution {\npublic:\nvector<int> sortArrayByParity(vector<int>& nums) {\n    int left = 0, right = nums.size() - 1;\n\n    while (left < right) {\n        // Move the left pointer to the right until it points to an odd number\n        while (left < right && nums[left] % 2 == 0) {\n            left++;\n        }\n\n        // Move the right pointer to the left until it points to an even number\n        while (left < right && nums[right] % 2 == 1) {\n            right--;\n        }\n\n        // Swap the elements at left and right pointers\n        swap(nums[left], nums[right]);\n    }\n\n    return nums;\n}\n};\n```
['Array', 'Two Pointers', 'Sorting', 'C++']