Given a 2D array of integers, write a function to flatten it into a single array. The function should not modify the original array. Examples: Input: [[1, 2], [3, 4], [5, 6]] Output: [1, 2, 3, 4, 5, 6] Constraints: The input array may be empty, and the sub-arrays may also be empty. The input will always be a 2D array.
Given a 2D array of integers, write a function to flatten it into a single array. The function should not modify the original array. Examples: Input: [[1, 2], [3, 4], [5, 6]] Output: [1, 2, 3, 4, 5, 6] Constraints: The input array may be empty, and the sub-arrays may also be empty. The input will always be a 2D array.
Example
Input: [[1, 2], [3, 4], [5, 6]]
Output: [1, 2, 3, 4, 5, 6]