Skip to content

Commit 18093d0

Browse files
committed
feat: add new leetcode problems
1 parent 02aee9a commit 18093d0

File tree

13 files changed

+620
-1
lines changed

13 files changed

+620
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# [1832. 判断句子是否为全字母句](https://leetcode-cn.com/problems/check-if-the-sentence-is-pangram)
2+
3+
[English Version](/solution/1800-1899/1832.Check%20if%20the%20Sentence%20Is%20Pangram/README_EN.md)
4+
5+
## 题目描述
6+
7+
<!-- 这里写题目描述 -->
8+
9+
<p><strong>全字母句</strong> 指包含英语字母表中每个字母至少一次的句子。</p>
10+
11+
<p>给你一个仅由小写英文字母组成的字符串 <code>sentence</code> ,请你判断 <code>sentence</code> 是否为 <strong>全字母句</strong> 。</p>
12+
13+
<p>如果是,返回<em> </em><code>true</code> ;否则,返回<em> </em><code>false</code> 。</p>
14+
15+
<p> </p>
16+
17+
<p><strong>示例 1:</strong></p>
18+
19+
<pre>
20+
<strong>输入:</strong>sentence = "thequickbrownfoxjumpsoverthelazydog"
21+
<strong>输出:</strong>true
22+
<strong>解释:</strong><code>sentence</code> 包含英语字母表中每个字母至少一次。
23+
</pre>
24+
25+
<p><strong>示例 2:</strong></p>
26+
27+
<pre>
28+
<strong>输入:</strong>sentence = "leetcode"
29+
<strong>输出:</strong>false
30+
</pre>
31+
32+
<p> </p>
33+
34+
<p><strong>提示:</strong></p>
35+
36+
<ul>
37+
<li><code>1 <= sentence.length <= 1000</code></li>
38+
<li><code>sentence</code> 由小写英语字母组成</li>
39+
</ul>
40+
41+
42+
## 解法
43+
44+
<!-- 这里可写通用的实现逻辑 -->
45+
46+
<!-- tabs:start -->
47+
48+
### **Python3**
49+
50+
<!-- 这里可写当前语言的特殊实现逻辑 -->
51+
52+
```python
53+
54+
```
55+
56+
### **Java**
57+
58+
<!-- 这里可写当前语言的特殊实现逻辑 -->
59+
60+
```java
61+
62+
```
63+
64+
### **...**
65+
66+
```
67+
68+
```
69+
70+
<!-- tabs:end -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# [1832. Check if the Sentence Is Pangram](https://leetcode.com/problems/check-if-the-sentence-is-pangram)
2+
3+
[中文文档](/solution/1800-1899/1832.Check%20if%20the%20Sentence%20Is%20Pangram/README.md)
4+
5+
## Description
6+
7+
<p>A <strong>pangram</strong> is a sentence where every letter of the English alphabet appears at least once.</p>
8+
9+
<p>Given a string <code>sentence</code> containing only lowercase English letters, return<em> </em><code>true</code><em> if </em><code>sentence</code><em> is a <strong>pangram</strong>, or </em><code>false</code><em> otherwise.</em></p>
10+
11+
<p>&nbsp;</p>
12+
<p><strong>Example 1:</strong></p>
13+
14+
<pre>
15+
<strong>Input:</strong> sentence = &quot;thequickbrownfoxjumpsoverthelazydog&quot;
16+
<strong>Output:</strong> true
17+
<strong>Explanation:</strong> sentence contains at least one of every letter of the English alphabet.
18+
</pre>
19+
20+
<p><strong>Example 2:</strong></p>
21+
22+
<pre>
23+
<strong>Input:</strong> sentence = &quot;leetcode&quot;
24+
<strong>Output:</strong> false
25+
</pre>
26+
27+
<p>&nbsp;</p>
28+
<p><strong>Constraints:</strong></p>
29+
30+
<ul>
31+
<li><code>1 &lt;= sentence.length &lt;= 1000</code></li>
32+
<li><code>sentence</code> consists of lowercase English letters.</li>
33+
</ul>
34+
35+
36+
## Solutions
37+
38+
<!-- tabs:start -->
39+
40+
### **Python3**
41+
42+
```python
43+
44+
```
45+
46+
### **Java**
47+
48+
```java
49+
50+
```
51+
52+
### **...**
53+
54+
```
55+
56+
```
57+
58+
<!-- tabs:end -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# [1833. 雪糕的最大数量](https://leetcode-cn.com/problems/maximum-ice-cream-bars)
2+
3+
[English Version](/solution/1800-1899/1833.Maximum%20Ice%20Cream%20Bars/README_EN.md)
4+
5+
## 题目描述
6+
7+
<!-- 这里写题目描述 -->
8+
9+
<p>夏日炎炎,小男孩 Tony 想买一些雪糕消消暑。</p>
10+
11+
<p>商店中新到 <code>n</code> 支雪糕,用长度为 <code>n</code> 的数组 <code>costs</code> 表示雪糕的定价,其中 <code>costs[i]</code> 表示第 <code>i</code> 支雪糕的现金价格。Tony 一共有 <code>coins</code> 现金可以用于消费,他想要买尽可能多的雪糕。</p>
12+
13+
<p>给你价格数组 <code>costs</code> 和现金量 <code>coins</code> ,请你计算并返回 Tony 用 <code>coins</code> 现金能够买到的雪糕的 <strong>最大数量</strong> 。</p>
14+
15+
<p><strong>注意:</strong>Tony 可以按任意顺序购买雪糕。</p>
16+
17+
<p> </p>
18+
19+
<p><strong>示例 1:</strong></p>
20+
21+
<pre><strong>输入:</strong>costs = [1,3,2,4,1], coins = 7
22+
<strong>输出:</strong>4
23+
<strong>解释:</strong>Tony 可以买下标为 0、1、2、4 的雪糕,总价为 1 + 3 + 2 + 1 = 7
24+
</pre>
25+
26+
<p><strong>示例 2:</strong></p>
27+
28+
<pre><strong>输入:</strong>costs = [10,6,8,7,7,8], coins = 5
29+
<strong>输出:</strong>0
30+
<strong>解释:</strong>Tony 没有足够的钱买任何一支雪糕。
31+
</pre>
32+
33+
<p><strong>示例 3:</strong></p>
34+
35+
<pre><strong>输入:</strong>costs = [1,6,3,1,2,5], coins = 20
36+
<strong>输出:</strong>6
37+
<strong>解释:</strong>Tony 可以买下所有的雪糕,总价为 1 + 6 + 3 + 1 + 2 + 5 = 18 。
38+
</pre>
39+
40+
<p> </p>
41+
42+
<p><strong>提示:</strong></p>
43+
44+
<ul>
45+
<li><code>costs.length == n</code></li>
46+
<li><code>1 &lt;= n &lt;= 10<sup>5</sup></code></li>
47+
<li><code>1 &lt;= costs[i] &lt;= 10<sup>5</sup></code></li>
48+
<li><code>1 &lt;= coins &lt;= 10<sup>8</sup></code></li>
49+
</ul>
50+
51+
52+
## 解法
53+
54+
<!-- 这里可写通用的实现逻辑 -->
55+
56+
<!-- tabs:start -->
57+
58+
### **Python3**
59+
60+
<!-- 这里可写当前语言的特殊实现逻辑 -->
61+
62+
```python
63+
64+
```
65+
66+
### **Java**
67+
68+
<!-- 这里可写当前语言的特殊实现逻辑 -->
69+
70+
```java
71+
72+
```
73+
74+
### **...**
75+
76+
```
77+
78+
```
79+
80+
<!-- tabs:end -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# [1833. Maximum Ice Cream Bars](https://leetcode.com/problems/maximum-ice-cream-bars)
2+
3+
[中文文档](/solution/1800-1899/1833.Maximum%20Ice%20Cream%20Bars/README.md)
4+
5+
## Description
6+
7+
<p>It is a sweltering summer day, and a boy wants to buy some ice cream bars.</p>
8+
9+
<p>At the store, there are <code>n</code> ice cream bars. You are given an array <code>costs</code> of length <code>n</code>, where <code>costs[i]</code> is the price of the <code>i<sup>th</sup></code> ice cream bar in coins. The boy initially has <code>coins</code> coins to spend, and he wants to buy as many ice cream bars as possible.&nbsp;</p>
10+
11+
<p>Return <em>the <strong>maximum</strong> number of ice cream bars the boy can buy with </em><code>coins</code><em> coins.</em></p>
12+
13+
<p><strong>Note:</strong> The boy can buy the ice cream bars in any order.</p>
14+
15+
<p>&nbsp;</p>
16+
<p><strong>Example 1:</strong></p>
17+
18+
<pre>
19+
<strong>Input:</strong> costs = [1,3,2,4,1], coins = 7
20+
<strong>Output:</strong> 4
21+
<strong>Explanation: </strong>The boy can buy ice cream bars at indices 0,1,2,4 for a total price of 1 + 3 + 2 + 1 = 7.
22+
</pre>
23+
24+
<p><strong>Example 2:</strong></p>
25+
26+
<pre>
27+
<strong>Input:</strong> costs = [10,6,8,7,7,8], coins = 5
28+
<strong>Output:</strong> 0
29+
<strong>Explanation: </strong>The boy cannot afford any of the ice cream bars.
30+
</pre>
31+
32+
<p><strong>Example 3:</strong></p>
33+
34+
<pre>
35+
<strong>Input:</strong> costs = [1,6,3,1,2,5], coins = 20
36+
<strong>Output:</strong> 6
37+
<strong>Explanation: </strong>The boy can buy all the ice cream bars for a total price of 1 + 6 + 3 + 1 + 2 + 5 = 18.
38+
</pre>
39+
40+
<p>&nbsp;</p>
41+
<p><strong>Constraints:</strong></p>
42+
43+
<ul>
44+
<li><code>costs.length == n</code></li>
45+
<li><code>1 &lt;= n &lt;= 10<sup>5</sup></code></li>
46+
<li><code>1 &lt;= costs[i] &lt;= 10<sup>5</sup></code></li>
47+
<li><code>1 &lt;= coins &lt;= 10<sup>8</sup></code></li>
48+
</ul>
49+
50+
51+
## Solutions
52+
53+
<!-- tabs:start -->
54+
55+
### **Python3**
56+
57+
```python
58+
59+
```
60+
61+
### **Java**
62+
63+
```java
64+
65+
```
66+
67+
### **...**
68+
69+
```
70+
71+
```
72+
73+
<!-- tabs:end -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# [1834. 单线程 CPU](https://leetcode-cn.com/problems/single-threaded-cpu)
2+
3+
[English Version](/solution/1800-1899/1834.Single-Threaded%20CPU/README_EN.md)
4+
5+
## 题目描述
6+
7+
<!-- 这里写题目描述 -->
8+
9+
<p>给你一个二维数组 <code>tasks</code> ,用于表示 <code>n</code>​​​​​​ 项从 <code>0</code> 到 <code>n - 1</code> 编号的任务。其中 <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> 意味着第 <code>i<sup>​​​​​​</sup></code>​​​​ 项任务将会于 <code>enqueueTime<sub>i</sub></code> 时进入任务队列,需要 <code>processingTime<sub>i</sub></code><sub> </sub>的时长完成执行。</p>
10+
11+
<p>现有一个单线程 CPU ,同一时间只能执行 <strong>最多一项</strong> 任务,该 CPU 将会按照下述方式运行:</p>
12+
13+
<ul>
14+
<li>如果 CPU 空闲,且任务队列中没有需要执行的任务,则 CPU 保持空闲状态。</li>
15+
<li>如果 CPU 空闲,但任务队列中有需要执行的任务,则 CPU 将会选择 <strong>执行时间最短</strong> 的任务开始执行。如果多个任务具有同样的最短执行时间,则选择下标最小的任务开始执行。</li>
16+
<li>一旦某项任务开始执行,CPU 在 <strong>执行完整个任务</strong> 前都不会停止。</li>
17+
<li>CPU 可以在完成一项任务后,立即开始执行一项新任务。</li>
18+
</ul>
19+
20+
<p>返回<em> </em>CPU<em> </em>处理任务的顺序。</p>
21+
22+
<p> </p>
23+
24+
<p><strong>示例 1:</strong></p>
25+
26+
<pre><strong>输入:</strong>tasks = [[1,2],[2,4],[3,2],[4,1]]
27+
<strong>输出:</strong>[0,2,3,1]
28+
<strong>解释:</strong>事件按下述流程运行:
29+
- time = 1 ,任务 0 进入任务队列,可执行任务项 = {0}
30+
- 同样在 time = 1 ,空闲状态的 CPU 开始执行任务 0 ,可执行任务项 = {}
31+
- time = 2 ,任务 1 进入任务队列,可执行任务项 = {1}
32+
- time = 3 ,任务 2 进入任务队列,可执行任务项 = {1, 2}
33+
- 同样在 time = 3 ,CPU 完成任务 0 并开始执行队列中用时最短的任务 2 ,可执行任务项 = {1}
34+
- time = 4 ,任务 3 进入任务队列,可执行任务项 = {1, 3}
35+
- time = 5 ,CPU 完成任务 2 并开始执行队列中用时最短的任务 3 ,可执行任务项 = {1}
36+
- time = 6 ,CPU 完成任务 3 并开始执行任务 1 ,可执行任务项 = {}
37+
- time = 10 ,CPU 完成任务 1 并进入空闲状态
38+
</pre>
39+
40+
<p><strong>示例 2:</strong></p>
41+
42+
<pre><strong>输入:</strong>tasks = [[7,10],[7,12],[7,5],[7,4],[7,2]]
43+
<strong>输出:</strong>[4,3,2,0,1]
44+
<strong>解释:</strong>事件按下述流程运行:
45+
- time = 7 ,所有任务同时进入任务队列,可执行任务项 = {0,1,2,3,4}
46+
- 同样在 time = 7 ,空闲状态的 CPU 开始执行任务 4 ,可执行任务项 = {0,1,2,3}
47+
- time = 9 ,CPU 完成任务 4 并开始执行任务 3 ,可执行任务项 = {0,1,2}
48+
- time = 13 ,CPU 完成任务 3 并开始执行任务 2 ,可执行任务项 = {0,1}
49+
- time = 18 ,CPU 完成任务 2 并开始执行任务 0 ,可执行任务项 = {1}
50+
- time = 28 ,CPU 完成任务 0 并开始执行任务 1 ,可执行任务项 = {}
51+
- time = 40 ,CPU 完成任务 1 并进入空闲状态</pre>
52+
53+
<p> </p>
54+
55+
<p><strong>提示:</strong></p>
56+
57+
<ul>
58+
<li><code>tasks.length == n</code></li>
59+
<li><code>1 &lt;= n &lt;= 10<sup>5</sup></code></li>
60+
<li><code>1 &lt;= enqueueTime<sub>i</sub>, processingTime<sub>i</sub> &lt;= 10<sup>9</sup></code></li>
61+
</ul>
62+
63+
64+
## 解法
65+
66+
<!-- 这里可写通用的实现逻辑 -->
67+
68+
<!-- tabs:start -->
69+
70+
### **Python3**
71+
72+
<!-- 这里可写当前语言的特殊实现逻辑 -->
73+
74+
```python
75+
76+
```
77+
78+
### **Java**
79+
80+
<!-- 这里可写当前语言的特殊实现逻辑 -->
81+
82+
```java
83+
84+
```
85+
86+
### **...**
87+
88+
```
89+
90+
```
91+
92+
<!-- tabs:end -->

0 commit comments

Comments
 (0)