Skip to content

Commit c86cef2

Browse files
committed
feat: add new lc problems
1 parent 0f9fef3 commit c86cef2

18 files changed

+18294
-17968
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# [2978. Symmetric Coordinates](https://leetcode.cn/problems/symmetric-coordinates)
2+
3+
[English Version](/solution/2900-2999/2978.Symmetric%20Coordinates/README_EN.md)
4+
5+
## 题目描述
6+
7+
<!-- 这里写题目描述 -->
8+
9+
<p>Table: <font face="monospace"><code>Pairs</code></font></p>
10+
11+
<pre>
12+
+-------------+------+
13+
| Column Name | Type |
14+
+-------------+------+
15+
| X | int |
16+
| Y | int |
17+
+-------------+------+
18+
Each row includes X and Y, where both are integers. Table may contain duplicate values.
19+
</pre>
20+
21+
<p>Two coordindates <code>(X1, Y1)</code> and <code>(X2, Y2)</code> are said to be <strong>symmetric</strong> coordintes if <code>X1 == Y2</code> and <code>X2 == Y1</code>.</p>
22+
23+
<p>Write a solution that outputs, among all these <strong>symmetric</strong> <strong>coordintes</strong>, only those <strong>unique</strong> coordinates that satisfy the condition <code>X1 &lt;= Y1</code>.</p>
24+
25+
<p>Return <em>the result table ordered by </em><code>X</code> <em>and </em> <code>Y</code> <em>(respectively)</em> <em>in <strong>ascending order</strong></em>.</p>
26+
27+
<p>The result format is in the following example.</p>
28+
29+
<p>&nbsp;</p>
30+
<p><strong class="example">Example 1:</strong></p>
31+
32+
<pre>
33+
<strong>Input:</strong>
34+
Coordinates table:
35+
+----+----+
36+
| X | Y |
37+
+----+----+
38+
| 20 | 20 |
39+
| 20 | 20 |
40+
| 20 | 21 |
41+
| 23 | 22 |
42+
| 22 | 23 |
43+
| 21 | 20 |
44+
+----+----+
45+
<strong>Output:</strong>
46+
+----+----+
47+
| x | y |
48+
+----+----+
49+
| 20 | 20 |
50+
| 20 | 21 |
51+
| 22 | 23 |
52+
+----+----+
53+
<strong>Explanation:</strong>
54+
- (20, 20) and (20, 20) are symmetric coordinates because, X1 == Y2 and X2 == Y1. This results in displaying (20, 20) as a distinctive coordinates.
55+
- (20, 21) and (21, 20) are symmetric coordinates because, X1 == Y2 and X2 == Y1. However, only (20, 21) will be displayed because X1 &lt;= Y1.
56+
- (23, 22) and (22, 23) are symmetric coordinates because, X1 == Y2 and X2 == Y1. However, only (22, 23) will be displayed because X1 &lt;= Y1.
57+
The output table is sorted by X and Y in ascending order.
58+
</pre>
59+
60+
## 解法
61+
62+
<!-- 这里可写通用的实现逻辑 -->
63+
64+
<!-- tabs:start -->
65+
66+
### **SQL**
67+
68+
<!-- 这里可写当前语言的特殊实现逻辑 -->
69+
70+
```sql
71+
72+
```
73+
74+
<!-- tabs:end -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# [2978. Symmetric Coordinates](https://leetcode.com/problems/symmetric-coordinates)
2+
3+
[中文文档](/solution/2900-2999/2978.Symmetric%20Coordinates/README.md)
4+
5+
## Description
6+
7+
<p>Table: <font face="monospace"><code>Pairs</code></font></p>
8+
9+
<pre>
10+
+-------------+------+
11+
| Column Name | Type |
12+
+-------------+------+
13+
| X | int |
14+
| Y | int |
15+
+-------------+------+
16+
Each row includes X and Y, where both are integers. Table may contain duplicate values.
17+
</pre>
18+
19+
<p>Two coordindates <code>(X1, Y1)</code> and <code>(X2, Y2)</code> are said to be <strong>symmetric</strong> coordintes if <code>X1 == Y2</code> and <code>X2 == Y1</code>.</p>
20+
21+
<p>Write a solution that outputs, among all these <strong>symmetric</strong> <strong>coordintes</strong>, only those <strong>unique</strong> coordinates that satisfy the condition <code>X1 &lt;= Y1</code>.</p>
22+
23+
<p>Return <em>the result table ordered by </em><code>X</code> <em>and </em> <code>Y</code> <em>(respectively)</em> <em>in <strong>ascending order</strong></em>.</p>
24+
25+
<p>The result format is in the following example.</p>
26+
27+
<p>&nbsp;</p>
28+
<p><strong class="example">Example 1:</strong></p>
29+
30+
<pre>
31+
<strong>Input:</strong>
32+
Coordinates table:
33+
+----+----+
34+
| X | Y |
35+
+----+----+
36+
| 20 | 20 |
37+
| 20 | 20 |
38+
| 20 | 21 |
39+
| 23 | 22 |
40+
| 22 | 23 |
41+
| 21 | 20 |
42+
+----+----+
43+
<strong>Output:</strong>
44+
+----+----+
45+
| x | y |
46+
+----+----+
47+
| 20 | 20 |
48+
| 20 | 21 |
49+
| 22 | 23 |
50+
+----+----+
51+
<strong>Explanation:</strong>
52+
- (20, 20) and (20, 20) are symmetric coordinates because, X1 == Y2 and X2 == Y1. This results in displaying (20, 20) as a distinctive coordinates.
53+
- (20, 21) and (21, 20) are symmetric coordinates because, X1 == Y2 and X2 == Y1. However, only (20, 21) will be displayed because X1 &lt;= Y1.
54+
- (23, 22) and (22, 23) are symmetric coordinates because, X1 == Y2 and X2 == Y1. However, only (22, 23) will be displayed because X1 &lt;= Y1.
55+
The output table is sorted by X and Y in ascending order.
56+
</pre>
57+
58+
## Solutions
59+
60+
<!-- tabs:start -->
61+
62+
### **SQL**
63+
64+
```sql
65+
66+
```
67+
68+
<!-- tabs:end -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# [2979. Most Expensive Item That Can Not Be Bought](https://leetcode.cn/problems/most-expensive-item-that-can-not-be-bought)
2+
3+
[English Version](/solution/2900-2999/2979.Most%20Expensive%20Item%20That%20Can%20Not%20Be%20Bought/README_EN.md)
4+
5+
## 题目描述
6+
7+
<!-- 这里写题目描述 -->
8+
9+
<p>You are given two <strong>distinct</strong> <strong>prime</strong> numbers <code>primeOne</code> and <code>primeTwo</code>.</p>
10+
11+
<p>Alice and Bob are visiting a market. The market has an <strong>infinite</strong> number of items, for <strong>any</strong> positive integer <code>x</code> there exists an item whose price is <code>x</code>. Alice wants to buy some items from the market to gift to Bob. She has an <strong>infinite</strong> number of coins in the denomination <code>primeOne</code> and <code>primeTwo</code>. She wants to know the <strong>most expensive</strong> item she can <strong>not</strong> buy to gift to Bob.</p>
12+
13+
<p>Return <em>the price of the <strong>most expensive</strong> item which Alice can not gift to Bob</em>.</p>
14+
15+
<p>&nbsp;</p>
16+
<p><strong class="example">Example 1:</strong></p>
17+
18+
<pre>
19+
<strong>Input:</strong> primeOne = 2, primeTwo = 5
20+
<strong>Output:</strong> 3
21+
<strong>Explanation:</strong> The prices of items which cannot be bought are [1,3]. It can be shown that all items with a price greater than 3 can be bought using a combination of coins of denominations 2 and 5.
22+
</pre>
23+
24+
<p><strong class="example">Example 2:</strong></p>
25+
26+
<pre>
27+
<strong>Input:</strong> primeOne = 5, primeTwo = 7
28+
<strong>Output:</strong> 23
29+
<strong>Explanation:</strong> The prices of items which cannot be bought are [1,2,3,4,6,8,9,11,13,16,18,23]. It can be shown that all items with a price greater than 23 can be bought.
30+
</pre>
31+
32+
<p>&nbsp;</p>
33+
<p><strong>Constraints:</strong></p>
34+
35+
<ul>
36+
<li><code>1 &lt; primeOne, primeTwo &lt; 10<sup>4</sup></code></li>
37+
<li><code>primeOne</code>, <code>primeTwo</code> are prime numbers.</li>
38+
<li><code>primeOne * primeTwo &lt; 10<sup>5</sup></code></li>
39+
</ul>
40+
41+
## 解法
42+
43+
<!-- 这里可写通用的实现逻辑 -->
44+
45+
<!-- tabs:start -->
46+
47+
### **Python3**
48+
49+
<!-- 这里可写当前语言的特殊实现逻辑 -->
50+
51+
```python
52+
53+
```
54+
55+
### **Java**
56+
57+
<!-- 这里可写当前语言的特殊实现逻辑 -->
58+
59+
```java
60+
61+
```
62+
63+
### **C++**
64+
65+
```cpp
66+
67+
```
68+
69+
### **Go**
70+
71+
```go
72+
73+
```
74+
75+
### **...**
76+
77+
```
78+
79+
```
80+
81+
<!-- tabs:end -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# [2979. Most Expensive Item That Can Not Be Bought](https://leetcode.com/problems/most-expensive-item-that-can-not-be-bought)
2+
3+
[中文文档](/solution/2900-2999/2979.Most%20Expensive%20Item%20That%20Can%20Not%20Be%20Bought/README.md)
4+
5+
## Description
6+
7+
<p>You are given two <strong>distinct</strong> <strong>prime</strong> numbers <code>primeOne</code> and <code>primeTwo</code>.</p>
8+
9+
<p>Alice and Bob are visiting a market. The market has an <strong>infinite</strong> number of items, for <strong>any</strong> positive integer <code>x</code> there exists an item whose price is <code>x</code>. Alice wants to buy some items from the market to gift to Bob. She has an <strong>infinite</strong> number of coins in the denomination <code>primeOne</code> and <code>primeTwo</code>. She wants to know the <strong>most expensive</strong> item she can <strong>not</strong> buy to gift to Bob.</p>
10+
11+
<p>Return <em>the price of the <strong>most expensive</strong> item which Alice can not gift to Bob</em>.</p>
12+
13+
<p>&nbsp;</p>
14+
<p><strong class="example">Example 1:</strong></p>
15+
16+
<pre>
17+
<strong>Input:</strong> primeOne = 2, primeTwo = 5
18+
<strong>Output:</strong> 3
19+
<strong>Explanation:</strong> The prices of items which cannot be bought are [1,3]. It can be shown that all items with a price greater than 3 can be bought using a combination of coins of denominations 2 and 5.
20+
</pre>
21+
22+
<p><strong class="example">Example 2:</strong></p>
23+
24+
<pre>
25+
<strong>Input:</strong> primeOne = 5, primeTwo = 7
26+
<strong>Output:</strong> 23
27+
<strong>Explanation:</strong> The prices of items which cannot be bought are [1,2,3,4,6,8,9,11,13,16,18,23]. It can be shown that all items with a price greater than 23 can be bought.
28+
</pre>
29+
30+
<p>&nbsp;</p>
31+
<p><strong>Constraints:</strong></p>
32+
33+
<ul>
34+
<li><code>1 &lt; primeOne, primeTwo &lt; 10<sup>4</sup></code></li>
35+
<li><code>primeOne</code>, <code>primeTwo</code> are prime numbers.</li>
36+
<li><code>primeOne * primeTwo &lt; 10<sup>5</sup></code></li>
37+
</ul>
38+
39+
## Solutions
40+
41+
<!-- tabs:start -->
42+
43+
### **Python3**
44+
45+
```python
46+
47+
```
48+
49+
### **Java**
50+
51+
```java
52+
53+
```
54+
55+
### **C++**
56+
57+
```cpp
58+
59+
```
60+
61+
### **Go**
62+
63+
```go
64+
65+
```
66+
67+
### **...**
68+
69+
```
70+
71+
```
72+
73+
<!-- tabs:end -->

0 commit comments

Comments
 (0)