LintCode_373_奇偶分割数组
来源:互联网 发布:tuxera ntfs for mac 编辑:程序博客网 时间:2024/06/10 09:52
分割一个整数数组,使得奇数在前偶数在后。
样例
给定 [1, 2, 3, 4]
,返回 [1, 3, 2, 4]
。
挑战
在原数组中完成,不使用额外空间。
把偶数放后面就好了吧
public class Solution { /** * @param nums: an array of integers * @return: nothing */ public void partitionArray(int[] nums) { // write your code here; int max = nums.length - 1; int i = 0; while(i < max){ if(nums[i] % 2 == 0){ int tmp = nums[i]; nums[i] = nums[max]; nums[max] = tmp; max--; }else{ i++; } } }}
0 0
- LintCode_373_奇偶分割数组
- 题目:奇偶分割数组
- 奇偶分割数组
- 奇偶分割数组
- lintcode ----奇偶分割数组
- 奇偶分割数组
- 奇偶分割数组
- lintcode,奇偶分割数组
- LintCode373:奇偶分割数组
- 奇偶分割数组
- 奇偶分割数组
- 奇偶分割数组
- Lintcode奇偶分割数组
- 奇偶分割数组-LintCode
- lintcode-奇偶分割数组-373
- 奇偶分割数组(LintCode)
- 奇偶数组分割,原地进行
- Java实现-奇偶分割数组
- Java Map遍历方式方式及性能测试
- HDU 4725-J - The Shortest Path in Nya Graph-增点建图-层次网络-最短路
- 浅谈HTTP中Get与Post的区别
- 1011 of search
- Android 中的Intent Action 一览表
- LintCode_373_奇偶分割数组
- POJ 1113 Wall(求凸包周长)
- leetcode笔记:Remove Linked List Elements
- 1012 of search
- HTTP 请求方式: GET和POST的比较 3
- git历史版本修改合并到主分支
- py - understanding zip function
- POJ 2007 Scrambled Polygon(极角排序)
- Navicat for MySql 如何插入新记录