Java, write a function, please use for loop to solve this question

Question 9: Binary Partitioning k = 2 no_partitions = 2^k = 4 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Partitions: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Given an array of integers and an integer k as an arguement, you are tasked with writing a function that will return an array of partitions. Each partition represents a segment of the array that can be subdivided 2k times. static int[] [] partition (int[] array, int k) Example 1: int[] x = {3, 2, 4, 7}; int[] [] result = partition (x, 1); //{ {3, 2}, {4, 7} } Example 2: int[] x = {3, 2, 4, 7, 8, 9, 2, 3}; int[][] result = partition (x, 2); //{ {3, 2}, {4, 7}, {8, 9}, {2, 3} }

"Get 15% discount on your first 3 orders with us"
Use the following coupon
"FIRST15"

Order Now