Reorganize numbers
HardGiven an array of positive integers, your task is to reorganize the array so that all even numbers appear before the odd numbers.
The order of the numbers doesn't need to be preserved - as long as all evens show up first.
For example, given the input
[3, 5, 2, 1, 9, 8, 6, 7]
Your function should return:
[2, 8, 6, 3, 5, 1, 9, 7]
Solution
6 Essential Arrays Coding Interview Problems
Master Arrays by trying the coding challenges below.
- 1.Trade stock onceEasy
- 2.AdditionEasy
- 3.Find the smallestEasy
- 4.Reorganize numbersHard
- 5.Maximum subarrayHard
- 6.Container of waterHard