Skip to content

Commit f8f4fe4

Browse files
committed
feat: add new lc problems
1 parent 3cbca23 commit f8f4fe4

File tree

34 files changed

+3039
-819
lines changed

34 files changed

+3039
-819
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# [1999. Smallest Greater Multiple Made of Two Digits](https://leetcode-cn.com/problems/smallest-greater-multiple-made-of-two-digits)
2+
3+
[English Version](/solution/1900-1999/1999.Smallest%20Greater%20Multiple%20Made%20of%20Two%20Digits/README_EN.md)
4+
5+
## 题目描述
6+
7+
<!-- 这里写题目描述 -->
8+
9+
<p>Given three integers, <code>k</code>, <code>digit1</code>, and <code>digit2</code>, you want to find the <strong>smallest</strong> integer that is:</p>
10+
11+
<ul>
12+
<li><strong>Larger</strong> than <code>k</code>,</li>
13+
<li>A <strong>multiple</strong> of <code>k</code>, and</li>
14+
<li>Comprised of <strong>only</strong> the digits <code>digit1</code> and/or <code>digit2</code>.</li>
15+
</ul>
16+
17+
<p>Return <em>the <strong>smallest</strong> such integer. If no such integer exists or the integer exceeds the limit of a signed 32-bit integer (</em><code>2<sup>31</sup> - 1</code><em>), return </em><code>-1</code>.</p>
18+
19+
<p>&nbsp;</p>
20+
<p><strong>Example 1:</strong></p>
21+
22+
<pre>
23+
<strong>Input:</strong> k = 2, digit1 = 0, digit2 = 2
24+
<strong>Output:</strong> 20
25+
<strong>Explanation:</strong>
26+
20 is the first integer larger than 2, a multiple of 2, and comprised of only the digits 0 and/or 2.
27+
</pre>
28+
29+
<p><strong>Example 2:</strong></p>
30+
31+
<pre>
32+
<strong>Input:</strong> k = 3, digit1 = 4, digit2 = 2
33+
<strong>Output:</strong> 24
34+
<strong>Explanation:</strong>
35+
24 is the first integer larger than 3, a multiple of 3, and comprised of only the digits 4 and/or 2.
36+
</pre>
37+
38+
<p><strong>Example 3:</strong></p>
39+
40+
<pre>
41+
<strong>Input:</strong> k = 2, digit1 = 0, digit2 = 0
42+
<strong>Output:</strong> -1
43+
<strong>Explanation:
44+
</strong>No integer meets the requirements so return -1.
45+
</pre>
46+
47+
<p>&nbsp;</p>
48+
<p><strong>Constraints:</strong></p>
49+
50+
<ul>
51+
<li><code>1 &lt;= k &lt;= 1000</code></li>
52+
<li><code>0 &lt;= digit1 &lt;= 9</code></li>
53+
<li><code>0 &lt;= digit2 &lt;= 9</code></li>
54+
</ul>
55+
56+
## 解法
57+
58+
<!-- 这里可写通用的实现逻辑 -->
59+
60+
<!-- tabs:start -->
61+
62+
### **Python3**
63+
64+
<!-- 这里可写当前语言的特殊实现逻辑 -->
65+
66+
```python
67+
68+
```
69+
70+
### **Java**
71+
72+
<!-- 这里可写当前语言的特殊实现逻辑 -->
73+
74+
```java
75+
76+
```
77+
78+
### **...**
79+
80+
```
81+
82+
```
83+
84+
<!-- tabs:end -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# [1999. Smallest Greater Multiple Made of Two Digits](https://leetcode.com/problems/smallest-greater-multiple-made-of-two-digits)
2+
3+
[中文文档](/solution/1900-1999/1999.Smallest%20Greater%20Multiple%20Made%20of%20Two%20Digits/README.md)
4+
5+
## Description
6+
7+
<p>Given three integers, <code>k</code>, <code>digit1</code>, and <code>digit2</code>, you want to find the <strong>smallest</strong> integer that is:</p>
8+
9+
<ul>
10+
<li><strong>Larger</strong> than <code>k</code>,</li>
11+
<li>A <strong>multiple</strong> of <code>k</code>, and</li>
12+
<li>Comprised of <strong>only</strong> the digits <code>digit1</code> and/or <code>digit2</code>.</li>
13+
</ul>
14+
15+
<p>Return <em>the <strong>smallest</strong> such integer. If no such integer exists or the integer exceeds the limit of a signed 32-bit integer (</em><code>2<sup>31</sup> - 1</code><em>), return </em><code>-1</code>.</p>
16+
17+
<p>&nbsp;</p>
18+
<p><strong>Example 1:</strong></p>
19+
20+
<pre>
21+
<strong>Input:</strong> k = 2, digit1 = 0, digit2 = 2
22+
<strong>Output:</strong> 20
23+
<strong>Explanation:</strong>
24+
20 is the first integer larger than 2, a multiple of 2, and comprised of only the digits 0 and/or 2.
25+
</pre>
26+
27+
<p><strong>Example 2:</strong></p>
28+
29+
<pre>
30+
<strong>Input:</strong> k = 3, digit1 = 4, digit2 = 2
31+
<strong>Output:</strong> 24
32+
<strong>Explanation:</strong>
33+
24 is the first integer larger than 3, a multiple of 3, and comprised of only the digits 4 and/or 2.
34+
</pre>
35+
36+
<p><strong>Example 3:</strong></p>
37+
38+
<pre>
39+
<strong>Input:</strong> k = 2, digit1 = 0, digit2 = 0
40+
<strong>Output:</strong> -1
41+
<strong>Explanation:
42+
</strong>No integer meets the requirements so return -1.
43+
</pre>
44+
45+
<p>&nbsp;</p>
46+
<p><strong>Constraints:</strong></p>
47+
48+
<ul>
49+
<li><code>1 &lt;= k &lt;= 1000</code></li>
50+
<li><code>0 &lt;= digit1 &lt;= 9</code></li>
51+
<li><code>0 &lt;= digit2 &lt;= 9</code></li>
52+
</ul>
53+
54+
## Solutions
55+
56+
<!-- tabs:start -->
57+
58+
### **Python3**
59+
60+
```python
61+
62+
```
63+
64+
### **Java**
65+
66+
```java
67+
68+
```
69+
70+
### **...**
71+
72+
```
73+
74+
```
75+
76+
<!-- tabs:end -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# [2004. The Number of Seniors and Juniors to Join the Company](https://leetcode-cn.com/problems/the-number-of-seniors-and-juniors-to-join-the-company)
2+
3+
[English Version](/solution/2000-2099/2004.The%20Number%20of%20Seniors%20and%20Juniors%20to%20Join%20the%20Company/README_EN.md)
4+
5+
## 题目描述
6+
7+
<!-- 这里写题目描述 -->
8+
9+
<p>Table: <code>Candidates</code></p>
10+
11+
<pre>
12+
+-------------+------+
13+
| Column Name | Type |
14+
+-------------+------+
15+
| employee_id | int |
16+
| experience | enum |
17+
| salary | int |
18+
+-------------+------+
19+
employee_id is the primary key column for this table.
20+
experience is an enum with one of the values (&#39;Senior&#39;, &#39;Junior&#39;).
21+
Each row of this table indicates the id of a candidate, their monthly salary, and their experience.
22+
</pre>
23+
24+
<p>&nbsp;</p>
25+
26+
<p>A company wants to hire new employees. The budget of the company for the salaries is <code>$70000</code>. The company&#39;s criteria for hiring are:</p>
27+
28+
<ol>
29+
<li>Hiring the largest number of seniors.</li>
30+
<li>After hiring the maximum number of seniors, use the remaining budget to hire the largest number of juniors.</li>
31+
</ol>
32+
33+
<p>Write an SQL query to find the number of seniors and juniors hired under the mentioned criteria.</p>
34+
35+
<p>Return the result table in <strong>any order</strong>.</p>
36+
37+
<p>The query result format is in the following example.</p>
38+
39+
<p>&nbsp;</p>
40+
<p><strong>Example 1:</strong></p>
41+
42+
<pre>
43+
<strong>Input:</strong>
44+
Candidates table:
45+
+-------------+------------+--------+
46+
| employee_id | experience | salary |
47+
+-------------+------------+--------+
48+
| 1 | Junior | 10000 |
49+
| 9 | Junior | 10000 |
50+
| 2 | Senior | 20000 |
51+
| 11 | Senior | 20000 |
52+
| 13 | Senior | 50000 |
53+
| 4 | Junior | 40000 |
54+
+-------------+------------+--------+
55+
<strong>Output:</strong>
56+
+------------+---------------------+
57+
| experience | accepted_candidates |
58+
+------------+---------------------+
59+
| Senior | 2 |
60+
| Junior | 2 |
61+
+------------+---------------------+
62+
<strong>Explanation:</strong>
63+
We can hire 2 seniors with IDs (2, 11). Since the budget is $70000 and the sum of their salaries is $40000, we still have $30000 but they are not enough to hire the senior candidate with ID 13.
64+
We can hire 2 juniors with IDs (1, 9). Since the remaining budget is $30000 and the sum of their salaries is $20000, we still have $10000 but they are not enough to hire the junior candidate with ID 4.
65+
</pre>
66+
67+
<p><strong>Example 2:</strong></p>
68+
69+
<pre>
70+
<strong>Input:</strong>
71+
Candidates table:
72+
+-------------+------------+--------+
73+
| employee_id | experience | salary |
74+
+-------------+------------+--------+
75+
| 1 | Junior | 10000 |
76+
| 9 | Junior | 10000 |
77+
| 2 | Senior | 80000 |
78+
| 11 | Senior | 80000 |
79+
| 13 | Senior | 80000 |
80+
| 4 | Junior | 40000 |
81+
+-------------+------------+--------+
82+
<strong>Output:</strong>
83+
+------------+---------------------+
84+
| experience | accepted_candidates |
85+
+------------+---------------------+
86+
| Senior | 0 |
87+
| Junior | 3 |
88+
+------------+---------------------+
89+
<strong>Explanation:</strong>
90+
We cannot hire any seniors with the current budget as we need at least $80000 to hire one senior.
91+
We can hire all three juniors with the remaining budget.
92+
</pre>
93+
94+
## 解法
95+
96+
<!-- 这里可写通用的实现逻辑 -->
97+
98+
<!-- tabs:start -->
99+
100+
### **SQL**
101+
102+
<!-- 这里可写当前语言的特殊实现逻辑 -->
103+
104+
```sql
105+
106+
```
107+
108+
<!-- tabs:end -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# [2004. The Number of Seniors and Juniors to Join the Company](https://leetcode.com/problems/the-number-of-seniors-and-juniors-to-join-the-company)
2+
3+
[中文文档](/solution/2000-2099/2004.The%20Number%20of%20Seniors%20and%20Juniors%20to%20Join%20the%20Company/README.md)
4+
5+
## Description
6+
7+
<p>Table: <code>Candidates</code></p>
8+
9+
<pre>
10+
+-------------+------+
11+
| Column Name | Type |
12+
+-------------+------+
13+
| employee_id | int |
14+
| experience | enum |
15+
| salary | int |
16+
+-------------+------+
17+
employee_id is the primary key column for this table.
18+
experience is an enum with one of the values (&#39;Senior&#39;, &#39;Junior&#39;).
19+
Each row of this table indicates the id of a candidate, their monthly salary, and their experience.
20+
</pre>
21+
22+
<p>&nbsp;</p>
23+
24+
<p>A company wants to hire new employees. The budget of the company for the salaries is <code>$70000</code>. The company&#39;s criteria for hiring are:</p>
25+
26+
<ol>
27+
<li>Hiring the largest number of seniors.</li>
28+
<li>After hiring the maximum number of seniors, use the remaining budget to hire the largest number of juniors.</li>
29+
</ol>
30+
31+
<p>Write an SQL query to find the number of seniors and juniors hired under the mentioned criteria.</p>
32+
33+
<p>Return the result table in <strong>any order</strong>.</p>
34+
35+
<p>The query result format is in the following example.</p>
36+
37+
<p>&nbsp;</p>
38+
<p><strong>Example 1:</strong></p>
39+
40+
<pre>
41+
<strong>Input:</strong>
42+
Candidates table:
43+
+-------------+------------+--------+
44+
| employee_id | experience | salary |
45+
+-------------+------------+--------+
46+
| 1 | Junior | 10000 |
47+
| 9 | Junior | 10000 |
48+
| 2 | Senior | 20000 |
49+
| 11 | Senior | 20000 |
50+
| 13 | Senior | 50000 |
51+
| 4 | Junior | 40000 |
52+
+-------------+------------+--------+
53+
<strong>Output:</strong>
54+
+------------+---------------------+
55+
| experience | accepted_candidates |
56+
+------------+---------------------+
57+
| Senior | 2 |
58+
| Junior | 2 |
59+
+------------+---------------------+
60+
<strong>Explanation:</strong>
61+
We can hire 2 seniors with IDs (2, 11). Since the budget is $70000 and the sum of their salaries is $40000, we still have $30000 but they are not enough to hire the senior candidate with ID 13.
62+
We can hire 2 juniors with IDs (1, 9). Since the remaining budget is $30000 and the sum of their salaries is $20000, we still have $10000 but they are not enough to hire the junior candidate with ID 4.
63+
</pre>
64+
65+
<p><strong>Example 2:</strong></p>
66+
67+
<pre>
68+
<strong>Input:</strong>
69+
Candidates table:
70+
+-------------+------------+--------+
71+
| employee_id | experience | salary |
72+
+-------------+------------+--------+
73+
| 1 | Junior | 10000 |
74+
| 9 | Junior | 10000 |
75+
| 2 | Senior | 80000 |
76+
| 11 | Senior | 80000 |
77+
| 13 | Senior | 80000 |
78+
| 4 | Junior | 40000 |
79+
+-------------+------------+--------+
80+
<strong>Output:</strong>
81+
+------------+---------------------+
82+
| experience | accepted_candidates |
83+
+------------+---------------------+
84+
| Senior | 0 |
85+
| Junior | 3 |
86+
+------------+---------------------+
87+
<strong>Explanation:</strong>
88+
We cannot hire any seniors with the current budget as we need at least $80000 to hire one senior.
89+
We can hire all three juniors with the remaining budget.
90+
</pre>
91+
92+
## Solutions
93+
94+
<!-- tabs:start -->
95+
96+
### **SQL**
97+
98+
```sql
99+
100+
```
101+
102+
<!-- tabs:end -->

0 commit comments

Comments
 (0)