Problem Statement:
You are given two arrays, change and arr, of lengths n and m, respectively. In each operation, you can perform one of the following:
You can decrement any element of arr by 1.
If change[i] > 0 and arr[change[i]] = 0, you can change that element to NULL.
Assume 1-based indexing and find the minimum number of operations required to change all elements of the array to NULL, or report -1 if not possible.
Example:
n = 4, m = 2
change = [0, 1, 0, 2]
arr = [1, 1]
Operations sequence:
Decrement arr[1]: [0, 1]
Change arr[1] to NULL since change[2] = 1 and arr[1] = 0: [NULL, 1]
Decrement arr[2]: [NULL, 0]
(... sequence continues to nullify the remaining elements)
Problem Statement:
Alex is attending a software engineering conference in which various lectures are presented. The subject matter of each lecture has a certain complexity. Alex has planned the order of lectures they would like to attend, but now they need to schedule these into several days.
Their goal is to attend at least one lecture every day and to plan the lectures in a way that minimizes the overall complexity of the conference. (Each day's complexity is defined as the complexity of the most complex lecture attended that day.)
Given the complexity levels of the lectures, as well as how many days the conference is being held, what is the overall minimum complexity that can be achieved with optimal planning?
Example:
For example, let's say there are n = 5 lectures, where complexity = [1, 5, 3, 2, 4], and the length of the conference is days = 2.
(Note that complexity denotes both the complexity of each lecture as well as the order in which they need to be attended...)