Given an array A of non-negative integers, return an array consisting of all the even elements of A, followed by all the odd elements of A.
You may return any answer array that satisfies this condition.
Example 1:
```
Input: [3,1,2,4]
Output: [2,4,3,1]
The outputs [4,2,3,1], [2,4,1,3], and [4,2,1,3] would also be accepted.
```
Note:
```
1 <= A.length <= 5000
0 <= A[i] <= 5000
```
```
/**
* @param {number[]} A
* @return {number[]}
*/
var sortArrayByParity = function(A) {
var l=0
var r=A.length-1;
while(l<r){
if(A[l] % 2 == 0){
l++;
}else{
var temp = A[r];
A[r] = A[l];
A[l] = temp;
r--
}
}
return A
};
```
- 说明
- 排序
- java实现
- 二分归并排序
- 快速排序
- js实现
- 冒泡排序 (Bubble Sort)
- 快速排序-js
- ES6-rest参数
- 比较排序
- 堆排序
- 插入排序
- 归并排序
- 选择排序
- shellSort
- 排序基础知识
- 其他
- Rabbit
- chickenProblem
- 汉诺塔
- 取出两个字符串中开头相同的部分
- 两个七进制输入,输出七进制
- 二维数组(矩阵)对角线输出
- 根据概率取值
- 最小编辑距离算法
- 列划分算法
- 数组去重
- 数组去重1
- 在一天里,钟表的时针和分针会重合多少次?
- 找第二大问题
- Raft算法
- B-tree
- Leetcode JAVA实现
- leetcode1. 2 Sum
- leetcode2. Add Two Numbers
- leetcode7. Reverse Integer
- leetcode8. String to Integer (atoi)
- leetcode12. Integer to Roman
- leetcode13. Roman to Integer
- leetcode15. 3Sum
- leetcode18. 4Sum
- leetcode20. Valid Parentheses
- leetcode26. Remove Duplicates from Sorted Array
- leetcode27. Remove Element
- leetcode58. Length of Last Word
- leetcode66. Plus One
- leetcode67. Add Binary
- leetcode80. Remove Duplicates from Sorted Array II
- leetcode 88. Merge Sorted Array
- leetcode101. Symmetric Tree
- leetcode104. Maximum Depth of Binary Tree
- leetcode110. Balanced Binary Tree
- leetcode118. Pascal's Triangle
- leetcode119. Pascal's Triangle II
- leetcode121. Best Time to Buy and Sell Stock
- leetcode125. Valid Palindrome
- leetcode136. Single Number
- leetcode144. Binary Tree Preorder Traversal
- leetcode145. Binary Tree Postorder Traversal
- leetcode155. Min Stack
- leetcode169. Majority Element
- leetcode171. Excel Sheet Column Number
- leetcode172. Factorial Trailing Zeroes
- leetcode189. Rotate Array
- leetcode191. Number of 1 Bits
- leetcode202. Happy Number
- leetcode203. Remove Linked List Elements
- leetcode204. Count Primes
- leetcode225. Implement Stack using Queues
- leetcode226. Invert Binary Tree
- leetcode231. Power of Two
- leetcode232. Implement Queue using Stacks
- leetcode234. Palindrome Linked List
- leetcode237. Delete Node in a Linked List
- leetcode242. Valid Anagram
- leetcode258. Add Digits
- leetcode263. Ugly Number
- leetcode283. Move Zeroes
- leetcode292. Nim Game
- leetcode344. Reverse String
- leetcode371. Sum of Two Integers
- leetcode804. Unique Morse Code Words
- Leetcode JS 实现
- Js-leetcode 1. Two Sum
- Js-leetcode 2. Add Two Numbers
- Js-leetcode 10. Regular Expression Matching
- Js-leetcode 14. Longest Common Prefix
- Js-leetcode 17.Letter Combinations of a Phone Number
- Js-leetcode 20. Valid Parentheses
- Js-leetcode 27. Remove Element
- Js-leetcode 30. Substring with Concatenation of All Words
- Js-leetcode 35. Search Insert Position
- Js-leetcode 41. First Missing Positive
- Js-leetcode 48. Rotate Image
- Js-leetcode 53. Maximum Subarray
- Js-leetcode 54. Spiral Matrix
- Js-leetcode 73. Set Matrix Zeroes
- Js-leetcode 75. Sort Colors
- Js-leetcode 85. Maximal Rectangle
- Js-leetcode 89. Gray Code
- Js-leetcode 93.Restore IP Addresses
- Js-leetcode 98. Validate Binary Search Tree
- Js-leetcode 104. Maximum Depth of Binary Tree
- Js-leetcode 118. Pascal's Triangle
- Js-leetcode 121. Best Time to Buy and Sell Stock
- Js-leetcode 136. Single Number
- Js-leetcode 164. Maximum Gap
- Js-leetcode 189. Rotate Array
- Js-leetcode 215. Kth Largest Element in an Array
- Js-leetcode 217. Contains Duplicate
- Js-leetcode 258. Add Digits
- Js-leetcode 263.Ugly Number
- Js-leetcode 283. Move Zeroes
- Js-leetcode 326. Power of Three
- Js-leetcode 434. Number of Segments in a String
- Js-leetcode 459. Repeated Substring Pattern
- Js-leetcode 507. Perfect Number
- Js-leetcode 537. Complex Number Multiplication
- Js-leetcode 541. Reverse String II
- Js-leetcode 551. Student Attendance Record I
- Js-leetcode 557. Reverse Words in a String III
- Js-leetcode 605. Can Place Flowers
- Js-leetcode 606. Construct String from Binary Tree
- Js-leetcode 621. Task Scheduler
- Js-leetcode 622. Design Circular Queue
- Js-leetcode 633. Sum of Square Numbers
- Js-leetcode 657. Robot Return to Origin
- Js-leetcode 682. Baseball Game
- Js-leetcode 686. Repeated String Match
- Js-leetcode 696. Count Binary Substrings
- Js-leetcode 709.To Lower Case.md
- Js-leetcode 771 Jewels and Stones
- Js-leetcode 804.Unique Morse Code Words
- Js-leetcode 867. Transpose Matrix
- Js-leetcode 905. Sort Array By Parity
- Js-leetcode 914. X of a Kind in a Deck of Cards
- Js-leetcode 922. Sort Array By Parity II
- Js-leetcode 1221. Split a String in Balanced Strings
- Js-leetcode 3. Longest substring without repeating characters
- document
- 刘宇波老师--基础知识
- 算法与数据结构
- 数据机构与算法介绍
- 二叉树
- 堆
- 链表
- 队列
- 并查集
- 最小生成树
- 图论
- 最短路径
- 总结
- 玩转数据结构
- 介绍
- 数组
- 栈和队列
- 玩转链表
- 链表与递归
- 二分搜索树
- 集合与映射
- 第8章 优先队列和堆
- 第9章 线段树
- 第10章 Trie
- 玩转算法面试 leetcode题库分门别类详细解析
- 第一章 介绍
- 第二章 时间复杂度和空间复杂度
- 第三章
- 深度实战玩转算法
- JS数据结构与算法
- 第一章.介绍
- 第二章.字符串
- 第三章.数组
- 第四章
- 第五章.排序
- 第六章.递归
- 第七章.栈
- 第八章.队列
- 第九章.链表
- 第十章.矩阵
- 第十一章.二叉树
- 第十二章.堆
- 极客时间
- 第01课丨数据结构与算法总览
- 第02课丨训练准备和复杂度分析
- 第03课丨数组、链表、跳表
- 第04课丨栈、队列、优先队列、双端队列
- 算法基础
- 哈希表(散列表)
- 异或运算
- leetcode
- KD树(K-Dimension Tree)
- Rtree
- B站-左神
- 一周刷爆LeetCode,算法大神左神(左程云)耗时100天打造算法与数据结构基础到高级全家桶教程,直击BTAJ等一线大厂必问算法面试题真题详解
- 简单的排序算法
- 认识Nlog(N)的算法
- 第三节:桶排序及排序算法总结
- 左程云算法课程
- 1 认识复杂度、对数器、二分法与异或运算
- 2 链表结构、栈、队列、递归行为、哈希表和有序表
- 10道BAT必问算法面试题
- 超级水王问题
- 78节
- 04链表