Skip to content

Commit 1f01b67

Browse files
committed
feat: update lc problem
1 parent 1529bbf commit 1f01b67

5 files changed

Lines changed: 255 additions & 1 deletion

File tree

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
---
2+
comments: true
3+
difficulty: 中等
4+
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3800-3899/3893.Maximum%20Team%20Size%20with%20Overlapping%20Intervals/README.md
5+
---
6+
7+
<!-- problem:start -->
8+
9+
# [3893. Maximum Team Size with Overlapping Intervals 🔒](https://leetcode.cn/problems/maximum-team-size-with-overlapping-intervals)
10+
11+
[English Version](/solution/3800-3899/3893.Maximum%20Team%20Size%20with%20Overlapping%20Intervals/README_EN.md)
12+
13+
## 题目描述
14+
15+
<!-- description:start -->
16+
17+
<p data-end="767" data-start="694">You are given two integer arrays <code>startTime</code> and <code>endTime</code> of length <code>n</code>.</p>
18+
19+
<ul>
20+
<li><code>startTime[i]</code> represents the start time of the <code>i<sup>th</sup></code> employee.</li>
21+
<li><code>endTime[i]</code> represents the end time of the <code>i<sup>th</sup></code> employee.</li>
22+
</ul>
23+
24+
<p>Two employees <code>i</code> and <code>j</code> can interact if their time intervals <strong>overlap</strong>. Two intervals are considered overlapping if they share <strong>at least one</strong> common time point.</p>
25+
26+
<p>A team is <strong>valid</strong> if there exists <strong>at least one</strong> employee in the team who can interact with every other member of the team.</p>
27+
28+
<p>Return an integer denoting the <strong>maximum</strong> possible size of such a team.</p>
29+
30+
<p>&nbsp;</p>
31+
<p><strong class="example">Example 1:</strong></p>
32+
33+
<div class="example-block">
34+
<p><strong>Input:</strong> <span class="example-io">startTime = [1,2,3], endTime = [4,5,6]</span></p>
35+
36+
<p><strong>Output:</strong> <span class="example-io">3</span></p>
37+
38+
<p><strong>Explanation:</strong></p>
39+
40+
<ul>
41+
<li>For <code>i = 0</code> with interval <code>[1, 4]</code>.</li>
42+
<li>It overlaps with <code>i = 1</code> having interval <code>[2, 5]</code> and <code>i = 2</code> having interval <code>[3, 6]</code>.</li>
43+
<li>Thus, index 0 can interact with all other indices, so the team size is 3.</li>
44+
</ul>
45+
</div>
46+
47+
<p><strong class="example">Example 2:</strong></p>
48+
49+
<div class="example-block">
50+
<p><strong>Input:</strong> <span class="example-io">startTime = [2,5,8], endTime = [3,7,9]</span></p>
51+
52+
<p><strong>Output:</strong> <span class="example-io">1</span></p>
53+
54+
<p><strong>Explanation:</strong></p>
55+
56+
<ul>
57+
<li>For <code>i = 0</code>, interval <code>[2, 3]</code> does not overlap with <code>[5, 7]</code> or <code>[8, 9]</code>.</li>
58+
<li>For <code>i = 1</code>, interval <code>[5, 7]</code> does not overlap with <code>[2, 3]</code> or <code>[8, 9]</code>.</li>
59+
<li>For <code>i = 2</code>, interval <code>[8, 9]</code> does not overlap with <code>[2, 3]</code> or <code>[5, 7]</code>.</li>
60+
<li>Thus, no index can interact with others, so the maximum team size is 1.</li>
61+
</ul>
62+
</div>
63+
64+
<p><strong class="example">Example 3:</strong></p>
65+
66+
<div class="example-block">
67+
<p><strong>Input:</strong> <span class="example-io">startTime = [3,4,6], endTime = [8,5,7]</span></p>
68+
69+
<p><strong>Output:</strong> <span class="example-io">3</span></p>
70+
71+
<p><strong>Explanation:</strong></p>
72+
73+
<ul>
74+
<li>For <code>i = 0</code> with interval <code>[3, 8]</code>.</li>
75+
<li>It overlaps with <code>i = 1</code> having interval <code>[4, 5]</code> and <code>i = 2</code> having interval <code>[6, 7]</code>.</li>
76+
<li>Thus, index 0 can interact with all other indices, so the team size is 3.</li>
77+
</ul>
78+
</div>
79+
80+
<p>&nbsp;</p>
81+
<p><strong>Constraints:</strong></p>
82+
83+
<ul>
84+
<li><code>1 &lt;= n == startTime.length == endTime.length &lt;= 10<sup>5</sup></code></li>
85+
<li><code>0 &lt;= startTime[i] &lt;= endTime[i] &lt;= 10<sup>9</sup></code></li>
86+
</ul>
87+
88+
<!-- description:end -->
89+
90+
## 解法
91+
92+
<!-- solution:start -->
93+
94+
### 方法一
95+
96+
<!-- tabs:start -->
97+
98+
#### Python3
99+
100+
```python
101+
102+
```
103+
104+
#### Java
105+
106+
```java
107+
108+
```
109+
110+
#### C++
111+
112+
```cpp
113+
114+
```
115+
116+
#### Go
117+
118+
```go
119+
120+
```
121+
122+
<!-- tabs:end -->
123+
124+
<!-- solution:end -->
125+
126+
<!-- problem:end -->
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
---
2+
comments: true
3+
difficulty: Medium
4+
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3800-3899/3893.Maximum%20Team%20Size%20with%20Overlapping%20Intervals/README_EN.md
5+
---
6+
7+
<!-- problem:start -->
8+
9+
# [3893. Maximum Team Size with Overlapping Intervals 🔒](https://leetcode.com/problems/maximum-team-size-with-overlapping-intervals)
10+
11+
[中文文档](/solution/3800-3899/3893.Maximum%20Team%20Size%20with%20Overlapping%20Intervals/README.md)
12+
13+
## Description
14+
15+
<!-- description:start -->
16+
17+
<p data-end="767" data-start="694">You are given two integer arrays <code>startTime</code> and <code>endTime</code> of length <code>n</code>.</p>
18+
19+
<ul>
20+
<li><code>startTime[i]</code> represents the start time of the <code>i<sup>th</sup></code> employee.</li>
21+
<li><code>endTime[i]</code> represents the end time of the <code>i<sup>th</sup></code> employee.</li>
22+
</ul>
23+
24+
<p>Two employees <code>i</code> and <code>j</code> can interact if their time intervals <strong>overlap</strong>. Two intervals are considered overlapping if they share <strong>at least one</strong> common time point.</p>
25+
26+
<p>A team is <strong>valid</strong> if there exists <strong>at least one</strong> employee in the team who can interact with every other member of the team.</p>
27+
28+
<p>Return an integer denoting the <strong>maximum</strong> possible size of such a team.</p>
29+
30+
<p>&nbsp;</p>
31+
<p><strong class="example">Example 1:</strong></p>
32+
33+
<div class="example-block">
34+
<p><strong>Input:</strong> <span class="example-io">startTime = [1,2,3], endTime = [4,5,6]</span></p>
35+
36+
<p><strong>Output:</strong> <span class="example-io">3</span></p>
37+
38+
<p><strong>Explanation:</strong></p>
39+
40+
<ul>
41+
<li>For <code>i = 0</code> with interval <code>[1, 4]</code>.</li>
42+
<li>It overlaps with <code>i = 1</code> having interval <code>[2, 5]</code> and <code>i = 2</code> having interval <code>[3, 6]</code>.</li>
43+
<li>Thus, index 0 can interact with all other indices, so the team size is 3.</li>
44+
</ul>
45+
</div>
46+
47+
<p><strong class="example">Example 2:</strong></p>
48+
49+
<div class="example-block">
50+
<p><strong>Input:</strong> <span class="example-io">startTime = [2,5,8], endTime = [3,7,9]</span></p>
51+
52+
<p><strong>Output:</strong> <span class="example-io">1</span></p>
53+
54+
<p><strong>Explanation:</strong></p>
55+
56+
<ul>
57+
<li>For <code>i = 0</code>, interval <code>[2, 3]</code> does not overlap with <code>[5, 7]</code> or <code>[8, 9]</code>.</li>
58+
<li>For <code>i = 1</code>, interval <code>[5, 7]</code> does not overlap with <code>[2, 3]</code> or <code>[8, 9]</code>.</li>
59+
<li>For <code>i = 2</code>, interval <code>[8, 9]</code> does not overlap with <code>[2, 3]</code> or <code>[5, 7]</code>.</li>
60+
<li>Thus, no index can interact with others, so the maximum team size is 1.</li>
61+
</ul>
62+
</div>
63+
64+
<p><strong class="example">Example 3:</strong></p>
65+
66+
<div class="example-block">
67+
<p><strong>Input:</strong> <span class="example-io">startTime = [3,4,6], endTime = [8,5,7]</span></p>
68+
69+
<p><strong>Output:</strong> <span class="example-io">3</span></p>
70+
71+
<p><strong>Explanation:</strong></p>
72+
73+
<ul>
74+
<li>For <code>i = 0</code> with interval <code>[3, 8]</code>.</li>
75+
<li>It overlaps with <code>i = 1</code> having interval <code>[4, 5]</code> and <code>i = 2</code> having interval <code>[6, 7]</code>.</li>
76+
<li>Thus, index 0 can interact with all other indices, so the team size is 3.</li>
77+
</ul>
78+
</div>
79+
80+
<p>&nbsp;</p>
81+
<p><strong>Constraints:</strong></p>
82+
83+
<ul>
84+
<li><code>1 &lt;= n == startTime.length == endTime.length &lt;= 10<sup>5</sup></code></li>
85+
<li><code>0 &lt;= startTime[i] &lt;= endTime[i] &lt;= 10<sup>9</sup></code></li>
86+
</ul>
87+
88+
<!-- description:end -->
89+
90+
## Solutions
91+
92+
<!-- solution:start -->
93+
94+
### Solution 1
95+
96+
<!-- tabs:start -->
97+
98+
#### Python3
99+
100+
```python
101+
102+
```
103+
104+
#### Java
105+
106+
```java
107+
108+
```
109+
110+
#### C++
111+
112+
```cpp
113+
114+
```
115+
116+
#### Go
117+
118+
```go
119+
120+
```
121+
122+
<!-- tabs:end -->
123+
124+
<!-- solution:end -->
125+
126+
<!-- problem:end -->

solution/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3903,6 +3903,7 @@
39033903
| 3890 | [可由多种立方和构造的整数](/solution/3800-3899/3890.Integers%20With%20Multiple%20Sum%20of%20Two%20Cubes/README.md) | | 中等 | 第 496 场周赛 |
39043904
| 3891 | [最大化特殊下标数目的最少增加次数](/solution/3800-3899/3891.Minimum%20Increase%20to%20Maximize%20Special%20Indices/README.md) | | 中等 | 第 496 场周赛 |
39053905
| 3892 | [产生至少 K 个峰值的最少操作次数](/solution/3800-3899/3892.Minimum%20Operations%20to%20Achieve%20At%20Least%20K%20Peaks/README.md) | | 困难 | 第 496 场周赛 |
3906+
| 3893 | [Maximum Team Size with Overlapping Intervals](/solution/3800-3899/3893.Maximum%20Team%20Size%20with%20Overlapping%20Intervals/README.md) | | 中等 | 🔒 |
39063907

39073908
## 版权
39083909

solution/README_EN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3901,6 +3901,7 @@ Press <kbd>Control</kbd> + <kbd>F</kbd>(or <kbd>Command</kbd> + <kbd>F</kbd> on
39013901
| 3890 | [Integers With Multiple Sum of Two Cubes](/solution/3800-3899/3890.Integers%20With%20Multiple%20Sum%20of%20Two%20Cubes/README_EN.md) | | Medium | Weekly Contest 496 |
39023902
| 3891 | [Minimum Increase to Maximize Special Indices](/solution/3800-3899/3891.Minimum%20Increase%20to%20Maximize%20Special%20Indices/README_EN.md) | | Medium | Weekly Contest 496 |
39033903
| 3892 | [Minimum Operations to Achieve At Least K Peaks](/solution/3800-3899/3892.Minimum%20Operations%20to%20Achieve%20At%20Least%20K%20Peaks/README_EN.md) | | Hard | Weekly Contest 496 |
3904+
| 3893 | [Maximum Team Size with Overlapping Intervals](/solution/3800-3899/3893.Maximum%20Team%20Size%20with%20Overlapping%20Intervals/README_EN.md) | | Medium | 🔒 |
39043905

39053906
## Copyright
39063907

solution/result.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)