# 905. Sort Array By Parity - LeetCode 原

yysue

## Question

905. Sort Array By Parity

## Solution

Java实现：

``````public int[] sortArrayByParity(int[] A) {
List<Integer> evenList = new ArrayList<>();
List<Integer> oddList = new ArrayList<>();
for (int i = 0; i < A.length; i++) {
if (A[i] % 2 == 0) evenList.add(A[i]);
}
int[] retArr = new int[A.length];
for (int i = 0; i < evenList.size(); i++) {
retArr[i] = evenList.get(i);
}
return retArr;
}
``````

### yysue

905. Sort Array By Parity

leetcode 上面有900多道题了？ 905. Sort Array By Parity 题意：给定一个一维数组，将数组中的偶数移动到数组的首部，奇数放在数组的尾部。 Input: [3,1,2,4]Output: [2,4,3,1]The outputs...

117
09/21
0
0
Leetcode In Golang

LeetCode Problems' Solutions LeetCode Problems 1. Two Sum 题意：给出一个数组(数字不重复)和目标值，输出数组元素和为目标值的两个元素的下标，当且仅当只有一个解。 思路： 1.暴力算法 ...

SpiffyEight77
11/29
0
0
992. Sort Array By Parity II - LeetCode

Question 992. Sort Array By Parity II Solution 题目大意：给一个int数组，一半是奇数一半是偶数，分别对偶数数和奇数数排序并要求这个数本身是偶数要放在偶数位上 思路：把奇数数和偶数数...

yysue
10/15
0
0
[CareerCup] 11.2 Sort Anagrams Array 异位词数组排序

11.2 Write a method to sort an array of strings so that all the anagrams are next to each other. 这道题让我们给一个字符串数组排序，让所有的变位词Anagrams排在一起，关于变位词，L...

2017/12/15
0
0
Sort Array By Parity

Sort Array By Parity 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 a......

Frost729
09/18
0
0

Java提高班（六）反射和动态代理（JDK Proxy和Cglib）

19分钟前
1
0
Ext grid 渲染

// 单元格字体颜色渲染function renderer_Meta_useStatus(value, cellmeta, record,rowIndex, columnIndex, store){ var color = ""; if("空闲"==value){ color = "green";......

MoksMo
28分钟前
4
0
log4j2在spring中的配置

<?xml version="1.0" encoding="UTF-8"?><!--日志级别以及优先级排序: OFF > FATAL > ERROR > WARN > INFO > DEBUG > TRACE > ALL --><!--Configuration后面的status，这个用于设置l......

TonyTaotao
34分钟前
3
0
java 中间变量缓存机制(i++,++i)

public class Test { public static void main(String[] args) { int i = 0; i = i ++ ; System.out.println(i); } } 答案是 0 如果是 i = ++......

shzwork
41分钟前
5
0

Java搬砖工程师
52分钟前
2
0