Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 80003a1

Browse files
committed
Create README - LeetHub
1 parent 5196ad9 commit 80003a1

File tree

1 file changed

+37
-0
lines changed
  • 2054-two-best-non-overlapping-events

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<h2><a href="https://leetcode.com/problems/two-best-non-overlapping-events/">2054. Two Best Non-Overlapping Events</a></h2><h3>Medium</h3><hr><div><p>You are given a <strong>0-indexed</strong> 2D integer array of <code>events</code> where <code>events[i] = [startTime<sub>i</sub>, endTime<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startTime<sub>i</sub></code><sub> </sub>and ends at <code>endTime<sub>i</sub></code>, and if you attend this event, you will receive a value of <code>value<sub>i</sub></code>. You can choose <strong>at most</strong> <strong>two</strong> <strong>non-overlapping</strong> events to attend such that the sum of their values is <strong>maximized</strong>.</p>
2+
3+
<p>Return <em>this <strong>maximum</strong> sum.</em></p>
4+
5+
<p>Note that the start time and end time is <strong>inclusive</strong>: that is, you cannot attend two events where one of them starts and the other ends at the same time. More specifically, if you attend an event with end time <code>t</code>, the next event must start at or after <code>t + 1</code>.</p>
6+
7+
<p>&nbsp;</p>
8+
<p><strong>Example 1:</strong></p>
9+
<img alt="" src="https://assets.leetcode.com/uploads/2021/09/21/picture5.png" style="width: 400px; height: 75px;">
10+
<pre><strong>Input:</strong> events = [[1,3,2],[4,5,2],[2,4,3]]
11+
<strong>Output:</strong> 4
12+
<strong>Explanation: </strong>Choose the green events, 0 and 1 for a sum of 2 + 2 = 4.
13+
</pre>
14+
15+
<p><strong>Example 2:</strong></p>
16+
<img alt="Example 1 Diagram" src="https://assets.leetcode.com/uploads/2021/09/21/picture1.png" style="width: 400px; height: 77px;">
17+
<pre><strong>Input:</strong> events = [[1,3,2],[4,5,2],[1,5,5]]
18+
<strong>Output:</strong> 5
19+
<strong>Explanation: </strong>Choose event 2 for a sum of 5.
20+
</pre>
21+
22+
<p><strong>Example 3:</strong></p>
23+
<img alt="" src="https://assets.leetcode.com/uploads/2021/09/21/picture3.png" style="width: 400px; height: 66px;">
24+
<pre><strong>Input:</strong> events = [[1,5,3],[1,5,1],[6,6,5]]
25+
<strong>Output:</strong> 8
26+
<strong>Explanation: </strong>Choose events 0 and 2 for a sum of 3 + 5 = 8.</pre>
27+
28+
<p>&nbsp;</p>
29+
<p><strong>Constraints:</strong></p>
30+
31+
<ul>
32+
<li><code>2 &lt;= events.length &lt;= 10<sup>5</sup></code></li>
33+
<li><code>events[i].length == 3</code></li>
34+
<li><code>1 &lt;= startTime<sub>i</sub> &lt;= endTime<sub>i</sub> &lt;= 10<sup>9</sup></code></li>
35+
<li><code>1 &lt;= value<sub>i</sub> &lt;= 10<sup>6</sup></code></li>
36+
</ul>
37+
</div>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /