原题链接

很水的一道题,就是数组内部交换。

水题就想着减少复杂度嘛,于是学到一种交换写法。

class Solution
{
public:
vector<int> sortArrayByParity(vector<int> &A)
{
int i = 0, j = A.size()-1;
while (i < j)
{
if (A[i] & 0x01)
{
A[i] ^= A[j];
A[j] ^= A[i];
A[i] ^= A[j];
--j;
}
else
++i;
}
return A;
}
};

[leetcode] 905. Sort Array By Parity [easy]的更多相关文章

  1. LeetCode 905. Sort Array By Parity

    905. Sort Array By Parity Given an array A of non-negative integers, return an array consisting of a ...

  2. [LeetCode] 905. Sort Array By Parity 按奇偶排序数组

    Given an array A of non-negative integers, return an array consisting of all the even elements of A, ...

  3. LeetCode 905 Sort Array By Parity 解题报告

    题目要求 Given an array A of non-negative integers, return an array consisting of all the even elements ...

  4. LeetCode 905. Sort Array By Parity 按奇偶校验排列数组

    题目 Given an array A of non-negative integers, return an array consisting of all the even elements of ...

  5. 【LEETCODE】41、905. Sort Array By Parity

    package y2019.Algorithm.array; /** * @ProjectName: cutter-point * @Package: y2019.Algorithm.array * ...

  6. 905. Sort Array By Parity - LeetCode

    Question 905. Sort Array By Parity Solution 题目大意:数组排序,偶数放前,奇数在后,偶数的数之间不用管顺序,奇数的数之间也不用管顺序 思路:建两个list, ...

  7. 【Leetcode_easy】905. Sort Array By Parity

    problem 905. Sort Array By Parity solution1: class Solution { public: vector<int> sortArrayByP ...

  8. [LeetCode] 922. 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 ...

  9. LeetCode 922. Sort Array By Parity II C++ 解题报告

    922. Sort Array By Parity II 题目描述 Given an array A of non-negative integers, half of the integers in ...

随机推荐

  1. Windows服务(system权限)程序显示界面与用户交互,Session0通知Session1里弹出对话框(真的很牛) good

    源码资源下载:http://download.csdn.net/detail/stony1980/4512984   1.VC2008中编写“Windows服务”(Windows Service)程序 ...

  2. <iOS小技巧> 返回上级目录操作Goback()方法

    Goback()方法功能:返回上一级界面,通过判断 popViewControllerAnimated 类型是否为空,来判断是present还是pop出来,然后直接做了releaseSelf操作: - ...

  3. Spring Boot:快速入门教程

    什么是Spring Boot? Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程.该框架使用了特定的方式来进行配置,从而使开发人 ...

  4. python文件及路径管理函数

    glob模块 说明: 1.glob是python自己带的一个文件操作相关模块,用它可以查找符合自己目的的文件,就类似于Windows下的文件搜索, 支持通配符操作 *.?.[] 这三个通配符,*代表0 ...

  5. python bmp image injection

    1. 将原BMP文件的第三,第四字节替换为\x2F\x2A, 对应js中的注释符号/*BMP文件的第三.四.五.六字节表示BMP文件的大小2. 在BMP文件末尾添加(1)\xFF(2)\x2A\x2F ...

  6. Git及基础命令的介绍以及如何向本地仓库添加文件

    在介绍Git的使用之前,我们得要先来了解一下Git.那么什么是Git? Git是一个版本管理工具(VCS),具有以下的特点: 分布式版本控制: 多个开发人员协调工作: 有效监听谁做的修改: 本地及远程 ...

  7. eclipse的安装与使用方法

    eclipse的安装与使用方法: eclipse是Java编程利器,工欲善其事必先利其器.下面我们来说说eclipse的安装与使用: 安装分三步: 第一步:安装eclipse 1.官网下载eclips ...

  8. python中的内置函数的思维导图

    https://mubu.com/doc/taq9-TBNix

  9. Effective Java第三版(一) ——用静态工厂代替构造器

    此文做为<Effective Java>系列的第一篇,所以有必要大概说下此书的特点,当然很多人可能都看过,毕竟是有着Java四大名著之一的大名在外,不过总会有萌新不了解,例如我!<E ...

  10. SpringBoot整合Swagger和Actuator

    前言 本篇文章主要介绍的是SpringBoot整合Swagger(API文档生成框架)和SpringBoot整合Actuator(项目监控)使用教程. SpringBoot整合Swagger 说明:如 ...