Feb-12-2020, 07:37 PM
Hi Expert,
I have a very though question to implement in python. It looks simple but hard. The question is as follow:
A student is preparing for the mid-semester exams and wants to make the least stressful schedule to study. There are 'n' subjects each of which has certain stress-level, and the student has 'days' study days left. The student must study the subjects in order, ie study the ith subject before going on to the (i+1)th subject.
The stress level of any day is defined as the maximum stress level of any subject the student studies on that day. Write a function to find the minimum stress level in which the student can finish studying all subjects, while still studying for at least one subject on each of the study days.
Constraints
1<= n <= 200
1<= days <= n <= 300
1<= stressLevel[i] <= 10^5
If days = 2, the solution is below:
Thank you for your help
cheerful
I have a very though question to implement in python. It looks simple but hard. The question is as follow:
A student is preparing for the mid-semester exams and wants to make the least stressful schedule to study. There are 'n' subjects each of which has certain stress-level, and the student has 'days' study days left. The student must study the subjects in order, ie study the ith subject before going on to the (i+1)th subject.
The stress level of any day is defined as the maximum stress level of any subject the student studies on that day. Write a function to find the minimum stress level in which the student can finish studying all subjects, while still studying for at least one subject on each of the study days.
Constraints
1<= n <= 200
1<= days <= n <= 300
1<= stressLevel[i] <= 10^5
If days = 2, the solution is below:
stresslevel = [30, 10, 40, 20, 50] # stresslevel = [1, 5, 3, 2, 4] n = len(stresslevel) days = 2 total_stress = [] for i in range(n-1): x = stresslevel[:i+1] y = stresslevel[i+1:] x_max = max(x) y_max = max(y) temp = x_max + y_max total_stress.append(temp) min_stress = min(total_stress) min_stressHowever, if days > 2 ie 5, it becomes difficult because there will be more pointers pointing to the stresslevel list and they will have to count up and down separately.
Thank you for your help
cheerful