# 905 Sort Array By Parity
清楚 Array 方法回傳了什麼、跟原本 Array 有沒有改變
Given an array A of non-negative integers,
return an array consisting of all the even elements of A,
followed by all the odd elements of A.
You may return any answer array that satisfies this condition.
input: 給一個沒有負數的數字陣列
output: 回傳前面是偶數後面是奇數的陣列Example 1:
Input: [3,1,2,4]
Output: [2,4,3,1]
The outputs [4,2,3,1], [2,4,1,3], and [4,2,1,3] would also be accepted.
Note:
1 <= A.length <= 5000
0 <= A[i] <= 5000
*/
/**
* @param {number[]} A
* @return {number[]}
*/
var sortArrayByParity = function(A) {
};Edge Case
哪種資料結構解
學到什麼?
Last updated