[C++] Simple Solution | Top 98.84% in 12 ms Runtime |  12ms & 60ms Solution Difference
Sort Array By Parity, Leetcode\n\nHere are Multiple Solution\'s with Different Complexities.\n\nMethod-1\n\n Run Time: 60ms.\n Top 6.85% in Run Time.\n\n\nclass
### Sort Array By Parity, Leetcode\n\nHere are Multiple Solution\'s with Different Complexities.\n\n**Method-1**\n\n* Run Time: 60ms.\n* Top 6.85% in Run Time.\n\n```\nclass Solution\n{\npublic:\n    vector<int> sortArrayByParity(vector<int> &A)\n    {\n        vector<int> result;\n\t\t//result.reserve(A.size());\n        for (int i = 0; i < A.size(); i++)\n        {\n            if (A[i] % 2 == 0)\n            {\n                result.insert(result.begin(), A[i]);\n            }\n            else\n            {\n                result.insert(result.end(), A[i]);\n            }\n        }\n        return result;\n    }\n};\n```\n\n**Method-2**\n\n**Without Using Extra Storage/Space(In Place)** \n\n* Run Time: 16ms.\n* Top 88.19% in Run Time.\n\n```\nclass Solution\n{\npublic:\n    vector<int> sortArrayByParity(vector<int> &A)\n    {\n        int size = A.size(), start = 0, end = size - 1;\n        while (start < end)\n        {\n            if (A[start] % 2 == 0)\n            {\n                start++;\n            }\n            else\n            {\n                swap(A[start], A[end]);\n                end--;\n            }\n        }\n        return A;\n    }\n};\n```\n\n**Method-3(Best)**\n\n* Run Time: 12ms.\n* Top 98.84% in Run Time.\n\n```\n\nclass Solution\n{\npublic:\n    vector<int> sortArrayByParity(vector<int> &A)\n    {\n        vector<int> result;\n\t\t//result.reserve(A.size());\n        for (int i = 0; i < A.size(); i++)\n        {\n            if (A[i] % 2 == 0)\n            {\n                result.push_back(A[i]);\n            }\n        }\n        for (int j = 0; j < A.size(); j++)\n        {\n            if (A[j] % 2 != 0)\n            {\n                result.push_back(A[j]);\n            }\n        }\n        return result;\n    }\n};\n```\n\n\n:)
[]