{"id":232,"date":"2018-10-14T19:45:55","date_gmt":"2018-10-14T11:45:55","guid":{"rendered":"https:\/\/www.ccagml.com\/?p=232"},"modified":"2018-11-29T14:46:53","modified_gmt":"2018-11-29T06:46:53","slug":"905-sort-array-by-parity","status":"publish","type":"post","link":"https:\/\/www.ccagml.com\/?p=232","title":{"rendered":"905. Sort Array By Parity"},"content":{"rendered":"<p>Given an array\u00a0<code>A<\/code>\u00a0of non-negative integers, return an array consisting of all the even elements of\u00a0<code>A<\/code>, followed by all the odd elements of\u00a0<code>A<\/code>.<\/p>\n<p>You may return any answer array that satisfies this condition.<\/p>\n<p>&nbsp;<\/p>\n<div>\n<p><strong>Example 1:<\/strong><\/p>\n<pre><strong>Input: <\/strong><span id=\"example-input-1-1\">[3,1,2,4]<\/span>\r\n<strong>Output: <\/strong><span id=\"example-output-1\">[2,4,3,1]<\/span>\r\nThe outputs [4,2,3,1], [2,4,1,3], and [4,2,1,3] would also be accepted.\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Note:<\/strong><\/p>\n<ol>\n<li><code>1 &lt;= A.length &lt;= 5000<\/code><\/li>\n<li><code>0 &lt;= A[i] &lt;= 5000<\/code><\/li>\n<\/ol>\n<\/div>\n<p><strong>Python<\/strong><\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\"> \r\nclass Solution(object):\r\n    def sortArrayByParity(self, A):\r\n        &quot;&quot;&quot;\r\n        :type A: List[int]\r\n        :rtype: List[int]\r\n        &quot;&quot;&quot;\r\n        return sorted(A, key=lambda s: s%2)\r\n        \r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Given an array\u00a0A\u00a0of non-negative integers, return an ar<a href=\"https:\/\/www.ccagml.com\/?p=232\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">905. Sort Array By Parity<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[29,20],"tags":[],"_links":{"self":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts\/232"}],"collection":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=232"}],"version-history":[{"count":1,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts\/232\/revisions"}],"predecessor-version":[{"id":233,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts\/232\/revisions\/233"}],"wp:attachment":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=232"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=232"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=232"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}