Partición de pares e impares
Escribe una función que divida el arreglo en dos subarreglos: uno con todos los números enteros pares y otro con todos los impares. Devuelve el resultado en el siguiente formato:
[[evens], [odds]]Ejemplos
Program.EvenOddPartition(new int[] { 5, 8, 9, 2, 0 }) ➞ new int[][] { new int[] { 8, 2, 0 }, new int[] { 5, 9 } }
Program.EvenOddPartition(new int[] { 1, 0, 1, 0, 1, 0 }) ➞ new int[][] { new int[] { 0, 0, 0 }, new int[] { 1, 1, 1 } }
Program.EvenOddPartition(new int[] { 1, 3, 5, 7, 9 }) ➞ new int[][] { new int[] { }, new int[] { 1, 3, 5, 7, 9 } }
Program.EvenOddPartition(new int[] { }) ➞ new int[][] { new int[] { }, new int[] { } }Notas
- Si el arreglo de entrada está vacío, devuelve dos subarreglos vacíos.
- Mantén el mismo orden relativo que en el arreglo original.