Skip to content

Commit 1d508a5

Browse files
committedJan 11, 2022
Add solution #905
1 parent 997eb5c commit 1d508a5

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed
 

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@
151151
876|[Middle of the Linked List](./0876-middle-of-the-linked-list.js)|Easy|
152152
884|[Uncommon Words from Two Sentences](./0884-uncommon-words-from-two-sentences.js)|Easy|
153153
890|[Find and Replace Pattern](./0890-find-and-replace-pattern.js)|Medium|
154+
905|[Sort Array By Parity](./0905-sort-array-by-parity.js)|Easy|
154155
916|[Word Subsets](./0916-word-subsets.js)|Medium|
155156
925|[Long Pressed Name](./0925-long-pressed-name.js)|Easy|
156157
929|[Unique Email Addresses](./0929-unique-email-addresses.js)|Easy|
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* 905. Sort Array By Parity
3+
* https://leetcode.com/problems/sort-array-by-parity/
4+
* Difficulty: Easy
5+
*
6+
* Given an integer array nums, move all the even integers at the beginning of
7+
* the array followed by all the odd integers.
8+
*
9+
* Return any array that satisfies this condition.
10+
*/
11+
12+
/**
13+
* @param {number[]} nums
14+
* @return {number[]}
15+
*/
16+
var sortArrayByParity = function(nums) {
17+
return nums.sort((a, b) => a % 2 === 0 ? -1 : 1);
18+
};

0 commit comments

Comments
 (0)
Please sign in to comment.