Hello and welcome back brave human being,

This past week we learned about intervals. This pattern was an absolute nightmare for me.

I’ve been procrastinating about doing this newsletter because I used to hate this pattern and today’s problem is our closing problem for intervals.

If you stare enough at it you can come up with a solution. It doesn’t have to be the most optimized solution. For today just come up with a solution.

Given an array interval of length N, where each element represents three values, i.e. {startTime, endTime, value}. The task is to find the maximum sum of values of at most two non-overlapping intervals.

Let's set an example…

Input: interval[] = [[1, 3, 2], [4, 5, 2], [2, 4, 3]]
Output: 4

Explanation: Select interval 1 and 2 (as third interval is overlapping). Therefore, maximum value is 2 + 2 = 4.

Remember aim for done not for perfect,

See you tomorrow with a solution,

Denisse

Need motivation to be consistent?

Add this problem to your log and when the challenge is done send it to me! You’ll be in for a treat.

Reply

Avatar

or to participate

Keep Reading