leetcode922
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的更多相关文章
- [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 ...
- Leetcode922.Sort Array By Parity II按奇偶排序数组2
给定一个非负整数数组 A, A 中一半整数是奇数,一半整数是偶数. 对数组进行排序,以便当 A[i] 为奇数时,i 也是奇数:当 A[i] 为偶数时, i 也是偶数. 你可以返回任何满足上述条件的数组 ...
- leetcode922 Sort Array By Parity II
""" Given an array A of non-negative integers, half of the integers in A are odd, and ...
随机推荐
- Rails 5 Test Prescriptions 第9章 Testing-JavaScript: Integration Testing,❌挂一个问题webpacker::helper
使用Capybara进行JS的集成测试 谈论驱动 让测试通过 Webpack in Development Mode Js设计 是用户在网页上有好的体验的重要因素. 尽管如此,许多网页不测试JS. 部 ...
- Manacher练习
看这篇博客学了下Manacher, 讲的很好, 但他的板子写错了.. https://www.cnblogs.com/Lyush/p/3221503.html 练习1 hdu 3068最长回文 板子题 ...
- HDU 4633 Who's Aunt Zhang ★(Polya定理 + 除法取模)
题意 用K个颜色给魔方染色,魔方只能整体旋转并且旋转重合的方案算一种,求一共有多少不同的染色方案. 思路 经典的Polya应用,记住正六面体的置换群就可以了,魔方就是每个大面变成9个小面了而已: 本题 ...
- ActiveX开发
转自(http://blog.csdn.net/mingojiang/article/details/8159263) 一.ActiveX基础 1.1什么是ActiveX ActiveX是COM规范的 ...
- 简单地为DBNavigator填加Caption
http://bbs.2ccc.com/topic.asp?topicid=346735 http://www.cnblogs.com/GarfieldTom/archive/2010/01/18/1 ...
- Xadmin的配置及使用
xadmin是Django的第三方扩展,可是使Django的admin站点使用更方便. 1. 安装 通过如下命令安装xadmin的最新版 pip install https://github.com/ ...
- scikit-learn 学习笔记-- Generalized Linear Models (一)
scikit-learn 是非常优秀的一个有关机器学习的 Python Lib,包含了除深度学习之外的传统机器学习的绝大多数算法,对于了解传统机器学习是一个很不错的平台.每个算法都有相应的例子,既可以 ...
- BZOJ3211: 花神游历各国(线段树)
3211: 花神游历各国 Time Limit: 5 Sec Memory Limit: 128 MBSubmit: 5692 Solved: 2114[Submit][Status][Discu ...
- 《DSP using MATLAB》示例 Example 10.2
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
- JavaWeb入门环境搭建
一.安装配置Tomcat 1.下载 2.配置环境变量 配置JAVA_HOME环境变量,路径为JDK的根目录 3.测试Tomcat 打开浏览器,在地址栏输入http://localhost:8080可以 ...