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. mybatis的xml配置中if text判断不为0

    问题:money_search_end != ‘0’为0时依然继续执行 解决方案: 1.单个字符要用''.toString() 2.用双引号“”,当然text的引号要改为单引号‘’ <if te ...

  2. hdu1564博弈+找规律

    #include<map> #include<set> #include<cmath> #include<queue> #include<stac ...

  3. git 使用和安装

    http://www.git-scm.com/download/ http://www.git-scm.com/download/win http://www.git-scm.com/download ...

  4. Mac下安装pcl-1.8.0

    更新,官方有Homebrew安装教程: http://pointclouds.org/documentation/tutorials/installing_homebrew.php#installin ...

  5. 菜鸟帮你跳过openstack配置过程中的坑[文末新添加福利]

    一:前言 对于一个以前做java全栈工程师而言,而且没学过Linux,很少用虚拟机(还是在大学的时候简单的用过),去配置openstack我想我入的坑肯定比有基础的一定要多,躺在每个坑中徘徊思索的时间 ...

  6. cvs的规范以及介绍(转)

    原文链接:http://blog.csdn.net/zlzlei/article/details/9236403 1. CSV的全称是叫Comma Separated Value 2. CSV的MIM ...

  7. 总线设备驱动模型---platform篇

    总线设备驱动模型----驱动篇 http://blog.chinaunix.net/uid-27664726-id-3334923.html http://blog.chinaunix.net/uid ...

  8. swift 分页视图

    var data:NSArray! var scrollView: UIScrollView! var pageCtrl: UIPageControl! override func viewDidLo ...

  9. Ubuntu tar方式安装mysql5.7.21 时报错 [ERROR] Can't locate the language directory. 以及 ------ libaio.so.1: cannot open shared object file

    参考帖子: http://blog.csdn.net/ty0415/article/details/22958133 首先,在 MySQL 官方网站上下载安装包, 如图: 然后,执行安装命令 bin/ ...

  10. hasura graphql 模式拼接概念

    具体的使用可以参考下面一张图 有一个术语 graphql-bindings 参考项目: https://github.com/hasura/generate-graphql-bindings http ...