Given an Array of integers where each element represent 1 to array[i] days. find maximum possible k consecutive days in circular array.
Example: arr = [7, 4, 6, 3, 5] k = 8 output = 33
explanation: we can choose last day of arr[4] (1,2,3,4,5)
which is 5 and all of 7 days of arr[1] (1,2,3,4,5,6,7)
. So, it will look like sum(5,1,2,3,4,5,6,7) = 33.
My thoughts: this look like classical sliding window problem to find max subarray of size k but converting original array to actual days array([1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 1, 2, 3, 1, 2, 3, 4, 5]) like this will not be optimal and what if size of k is far greater than length of array?.
Need help if anybody have some pointers how to solve this question.