Question: Given an array of n integers, design a greedy algorithm to find the partitions that divide the array into k non-empty subarrays with the
Given an array of n integers, design a greedy algorithm to find the partitions that divide the array into k non-empty subarrays with the equal sum (return false if not found). State your algorithm in English or pseudo code, and running time in big O notation. An example is as Array: [1, 3, -2, 7, 5, 4, 9, -4, 13], k = 4 Results: [1, 3, -2, 7], [5, 4], [9], [-4, 13]. Another example is as Array: [5, -2, -1, 4, 8, -8, 12], k = 3 Results: false Hint: you can calculate the sum for each subarray first.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
