public class Solution
{
public int[] SortArrayByParityII(int[] A)
{
var len = A.Length;
int[] ODD = new int[len / ];//奇数1,3,5,7,9
int[] EVEN = new int[len / ];//偶数0,2,4,6,8
int x = ;
int y = ;
for (int i = ; i < len; i++)
{
if (A[i] % == )
{
EVEN[x] = A[i];
x++;
}
else
{
ODD[y] = A[i];
y++;
}
}
x = ;
y = ;
for (int i = ; i < len; i++)
{
if (i % == )
{
A[i] = EVEN[x];
x++;
}
else
{
A[i] = ODD[y];
y++;
}
}
return A;
}
}

leetcode922的更多相关文章

  1. [Swift]LeetCode922.按奇偶排序数组 II | Sort Array By Parity II

    Given an array A of non-negative integers, half of the integers in A are odd, and half of the intege ...

  2. Leetcode922.Sort Array By Parity II按奇偶排序数组2

    给定一个非负整数数组 A, A 中一半整数是奇数,一半整数是偶数. 对数组进行排序,以便当 A[i] 为奇数时,i 也是奇数:当 A[i] 为偶数时, i 也是偶数. 你可以返回任何满足上述条件的数组 ...

  3. leetcode922 Sort Array By Parity II

    """ Given an array A of non-negative integers, half of the integers in A are odd, and ...

随机推荐

  1. hdu2188巴什博弈

    裸题,直接套公式 巴什游戏只是换了一个说法而已 #include<map> #include<set> #include<cmath> #include<qu ...

  2. hdu4686矩阵快速幂

    花了一个多小时终于ac了,有时候真的是需要冷静一下重新打一遍才行. 这题就是 |aod(n)|   =    |1        ax*bx       ax*by      ay*bx       ...

  3. ZOJ-3962-数位dp

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5594             16进制下的数位dp,由于固定了位数,可以出现前 ...

  4. UVA-10615 Rooks (二分图匹配)

    题目大意:在一个nxn的方格中,有些位置有车,要给每一个车都涂上颜色,使得同一行和同一列的任意两个车颜色不同,求一种需要颜色种数最少的涂色方案. 题目分析:所需的最少颜色种数是显然就能得出的,假设最少 ...

  5. 关闭定时器(setTimeout/clearTimeout|setInterval/clearInterval)

    1.1 开启Timeout程序: scope.setTimeout("functionName()" | functionHandle, timeValue) 返回值:timerI ...

  6. Git观察和比较

    log git log 时间是从下到上,从远到近   whatchanged git whatchanged 时间是从下到上,从远到近   diff --staged 比较工作区和缓存区之间的差异 g ...

  7. IIS7 部署 MVC3

    IIS7 部署 MVC3 (2013-02-28 11:06:39) 转载▼ 标签: iis7 mvc3 it 分类: ASP.NET 在IIS7下部署MVC已经简化了许多,基本按照一般的项目部署即可 ...

  8. php http build query

    http_build_query (PHP 5, PHP 7) http_build_query — 生成 URL-encode 之后的请求字符串 说明¶ string http_build_quer ...

  9. 回测框架pybacktest简介(二)

    pybacktest 的疑点 第(一)节“教程”原文,是用 ipython notebook 写成,程序代码是一些片段组成. 为了阅读方便,合并在一起. 本文转载于:http://blog.csdn. ...

  10. Ambiguous reference to member 'dataTask(with:completionHandle:)'错误

    在研究IOS的网络请求过程中,因为NSURLConnection已经过时,需要引用到URLSession var url:NSURL=NSURL(string: "http://3g.163 ...