Skip to content

Commit c470a2f

Browse files
committed
feat: add new lc problems
1 parent 4dd8462 commit c470a2f

File tree

23 files changed

+2399
-988
lines changed

23 files changed

+2399
-988
lines changed

index.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
<head>
55
<meta charset="UTF-8">
6-
<title>LeetCode & Coding Interview Guide</title>
6+
<title>LeetCode & Coding Interview Guide - Doocs Open Source Organization</title>
77
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
88
<meta name="keywords"
9-
content="doc,docs,doocs,documentation,github,gitee,coding,pages,leetcode,coding-interview,coding-interview-guide,cracking-the-coding-interview,yanglbme">
9+
content="doc,docs,doocs,documentation,github,gitee,coding,pages,leetcode,lcof,lcci,lcof2,coding-interview,coding-interview-guide,cracking-the-coding-interview,yanglbme">
1010
<meta name="description" content="LeetCode、剑指Offer、程序员面试金典题解">
1111
<meta name="viewport"
1212
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
@@ -22,7 +22,7 @@
2222
</head>
2323

2424
<body>
25-
<div id="app">LeetCode & Coding Interview Guide</div>
25+
<div id="app">LeetCode & Coding Interview Guide @Doocs</div>
2626
<script>
2727
window.$docsify = {
2828
name: 'leetcode',
@@ -123,4 +123,4 @@
123123
<script src="//cdn.jsdelivr.net/npm/docsify-darklight-theme@latest/dist/index.min.js"></script>
124124
</body>
125125

126-
</html>
126+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# [2022. 将一维数组转变成二维数组](https://leetcode-cn.com/problems/convert-1d-array-into-2d-array)
2+
3+
[English Version](/solution/2000-2099/2022.Convert%201D%20Array%20Into%202D%20Array/README_EN.md)
4+
5+
## 题目描述
6+
7+
<!-- 这里写题目描述 -->
8+
9+
<p>给你一个下标从 <strong>0</strong>&nbsp;开始的一维整数数组&nbsp;<code>original</code>&nbsp;和两个整数&nbsp;<code>m</code>&nbsp;&nbsp;&nbsp;<code>n</code>&nbsp;。你需要使用&nbsp;<code>original</code>&nbsp;&nbsp;<strong>所有</strong>&nbsp;元素创建一个&nbsp;<code>m</code>&nbsp;&nbsp;<code>n</code>&nbsp;列的二维数组。</p>
10+
11+
<p><code>original</code>&nbsp;中下标从 <code>0</code>&nbsp;到 <code>n - 1</code>&nbsp;(都 <strong>包含</strong> )的元素构成二维数组的第一行,下标从 <code>n</code>&nbsp;到 <code>2 * n - 1</code>&nbsp;(都 <strong>包含</strong>&nbsp;)的元素构成二维数组的第二行,依此类推。</p>
12+
13+
<p>请你根据上述过程返回一个<em>&nbsp;</em><code>m x n</code>&nbsp;的二维数组。如果无法构成这样的二维数组,请你返回一个空的二维数组。</p>
14+
15+
<p>&nbsp;</p>
16+
17+
<p><strong>示例 1:</strong></p>
18+
<img src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/2000-2099/2022.Convert%201D%20Array%20Into%202D%20Array/images/image-20210826114243-1.png" style="width: 500px; height: 174px;">
19+
<pre><b>输入:</b>original = [1,2,3,4], m = 2, n = 2
20+
<b>输出:</b>[[1,2],[3,4]]
21+
<strong>解释:
22+
</strong>构造出的二维数组应该包含 2 行 2 列。
23+
original 中第一个 n=2 的部分为 [1,2] ,构成二维数组的第一行。
24+
original 中第二个 n=2 的部分为 [3,4] ,构成二维数组的第二行。
25+
</pre>
26+
27+
<p><strong>示例 2:</strong></p>
28+
29+
<pre><b>输入:</b>original = [1,2,3], m = 1, n = 3
30+
<b>输出:</b>[[1,2,3]]
31+
<b>解释:</b>
32+
构造出的二维数组应该包含 1 行 3 列。
33+
将 original 中所有三个元素放入第一行中,构成要求的二维数组。
34+
</pre>
35+
36+
<p><strong>示例 3:</strong></p>
37+
38+
<pre><b>输入:</b>original = [1,2], m = 1, n = 1
39+
<b>输出:</b>[]
40+
<strong>解释:
41+
</strong>original 中有 2 个元素。
42+
无法将 2 个元素放入到一个 1x1 的二维数组中,所以返回一个空的二维数组。
43+
</pre>
44+
45+
<p><strong>示例 4:</strong></p>
46+
47+
<pre><b>输入:</b>original = [3], m = 1, n = 2
48+
<b>输出:</b>[]
49+
<strong>解释:</strong>
50+
original 中只有 1 个元素。
51+
无法将 1 个元素放满一个 1x2 的二维数组,所以返回一个空的二维数组。
52+
</pre>
53+
54+
<p>&nbsp;</p>
55+
56+
<p><strong>提示:</strong></p>
57+
58+
<ul>
59+
<li><code>1 &lt;= original.length &lt;= 5 * 10<sup>4</sup></code></li>
60+
<li><code>1 &lt;= original[i] &lt;= 10<sup>5</sup></code></li>
61+
<li><code>1 &lt;= m, n &lt;= 4 * 10<sup>4</sup></code></li>
62+
</ul>
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 -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# [2022. Convert 1D Array Into 2D Array](https://leetcode.com/problems/convert-1d-array-into-2d-array)
2+
3+
[中文文档](/solution/2000-2099/2022.Convert%201D%20Array%20Into%202D%20Array/README.md)
4+
5+
## Description
6+
7+
<p>You are given a <strong>0-indexed</strong> 1-dimensional (1D) integer array <code>original</code>, and two integers, <code>m</code> and <code>n</code>. You are tasked with creating a 2-dimensional (2D) array with <code> m</code> rows and <code>n</code> columns using <strong>all</strong> the elements from <code>original</code>.</p>
8+
9+
<p>The elements from indices <code>0</code> to <code>n - 1</code> (<strong>inclusive</strong>) of <code>original</code> should form the first row of the constructed 2D array, the elements from indices <code>n</code> to <code>2 * n - 1</code> (<strong>inclusive</strong>) should form the second row of the constructed 2D array, and so on.</p>
10+
11+
<p>Return <em>an </em><code>m x n</code><em> 2D array constructed according to the above procedure, or an empty 2D array if it is impossible</em>.</p>
12+
13+
<p>&nbsp;</p>
14+
<p><strong>Example 1:</strong></p>
15+
<img src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/2000-2099/2022.Convert%201D%20Array%20Into%202D%20Array/images/image-20210826114243-1.png" style="width: 500px; height: 174px;" />
16+
<pre>
17+
<strong>Input:</strong> original = [1,2,3,4], m = 2, n = 2
18+
<strong>Output:</strong> [[1,2],[3,4]]
19+
<strong>Explanation:
20+
</strong>The constructed 2D array should contain 2 rows and 2 columns.
21+
The first group of n=2 elements in original, [1,2], becomes the first row in the constructed 2D array.
22+
The second group of n=2 elements in original, [3,4], becomes the second row in the constructed 2D array.
23+
</pre>
24+
25+
<p><strong>Example 2:</strong></p>
26+
27+
<pre>
28+
<strong>Input:</strong> original = [1,2,3], m = 1, n = 3
29+
<strong>Output:</strong> [[1,2,3]]
30+
<b>Explanation:</b>
31+
The constructed 2D array should contain 1 row and 3 columns.
32+
Put all three elements in original into the first row of the constructed 2D array.
33+
</pre>
34+
35+
<p><strong>Example 3:</strong></p>
36+
37+
<pre>
38+
<strong>Input:</strong> original = [1,2], m = 1, n = 1
39+
<strong>Output:</strong> []
40+
<strong>Explanation:
41+
</strong>There are 2 elements in original.
42+
It is impossible to fit 2 elements in a 1x1 2D array, so return an empty 2D array.
43+
</pre>
44+
45+
<p><strong>Example 4:</strong></p>
46+
47+
<pre>
48+
<strong>Input:</strong> original = [3], m = 1, n = 2
49+
<strong>Output:</strong> []
50+
<strong>Explanation:</strong>
51+
There is 1 element in original.
52+
It is impossible to make 1 element fill all the spots in a 1x2 2D array, so return an empty 2D array.
53+
</pre>
54+
55+
<p>&nbsp;</p>
56+
<p><strong>Constraints:</strong></p>
57+
58+
<ul>
59+
<li><code>1 &lt;= original.length &lt;= 5 * 10<sup>4</sup></code></li>
60+
<li><code>1 &lt;= original[i] &lt;= 10<sup>5</sup></code></li>
61+
<li><code>1 &lt;= m, n &lt;= 4 * 10<sup>4</sup></code></li>
62+
</ul>
63+
64+
## Solutions
65+
66+
<!-- tabs:start -->
67+
68+
### **Python3**
69+
70+
```python
71+
72+
```
73+
74+
### **Java**
75+
76+
```java
77+
78+
```
79+
80+
### **...**
81+
82+
```
83+
84+
```
85+
86+
<!-- tabs:end -->
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# [2023. 连接后等于目标字符串的字符串对](https://leetcode-cn.com/problems/number-of-pairs-of-strings-with-concatenation-equal-to-target)
2+
3+
[English Version](/solution/2000-2099/2023.Number%20of%20Pairs%20of%20Strings%20With%20Concatenation%20Equal%20to%20Target/README_EN.md)
4+
5+
## 题目描述
6+
7+
<!-- 这里写题目描述 -->
8+
9+
<p>给你一个 <strong>数字</strong>&nbsp;字符串数组 <code>nums</code>&nbsp;和一个 <strong>数字</strong>&nbsp;字符串 <code>target</code>&nbsp;,请你返回 <code>nums[i] + nums[j]</code>&nbsp;(两个字符串连接)结果等于 <code>target</code>&nbsp;的下标 <code>(i, j)</code>&nbsp;(需满足 <code>i != j</code>)的数目。</p>
10+
11+
<p>&nbsp;</p>
12+
13+
<p><strong>示例 1:</strong></p>
14+
15+
<pre><b>输入:</b>nums = ["777","7","77","77"], target = "7777"
16+
<b>输出:</b>4
17+
<b>解释:</b>符合要求的下标对包括:
18+
- (0, 1):"777" + "7"
19+
- (1, 0):"7" + "777"
20+
- (2, 3):"77" + "77"
21+
- (3, 2):"77" + "77"
22+
</pre>
23+
24+
<p><strong>示例 2:</strong></p>
25+
26+
<pre><b>输入:</b>nums = ["123","4","12","34"], target = "1234"
27+
<b>输出:</b>2
28+
<b>解释:</b>符合要求的下标对包括
29+
- (0, 1):"123" + "4"
30+
- (2, 3):"12" + "34"
31+
</pre>
32+
33+
<p><strong>示例 3:</strong></p>
34+
35+
<pre><b>输入:</b>nums = ["1","1","1"], target = "11"
36+
<b>输出:</b>6
37+
<b>解释:</b>符合要求的下标对包括
38+
- (0, 1):"1" + "1"
39+
- (1, 0):"1" + "1"
40+
- (0, 2):"1" + "1"
41+
- (2, 0):"1" + "1"
42+
- (1, 2):"1" + "1"
43+
- (2, 1):"1" + "1"
44+
</pre>
45+
46+
<p>&nbsp;</p>
47+
48+
<p><strong>提示:</strong></p>
49+
50+
<ul>
51+
<li><code>2 &lt;= nums.length &lt;= 100</code></li>
52+
<li><code>1 &lt;= nums[i].length &lt;= 100</code></li>
53+
<li><code>2 &lt;= target.length &lt;= 100</code></li>
54+
<li><code>nums[i]</code>&nbsp;和&nbsp;<code>target</code>&nbsp;只包含数字。</li>
55+
<li><code>nums[i]</code>&nbsp;和&nbsp;<code>target</code>&nbsp;不含有任何前导 0 。</li>
56+
</ul>
57+
58+
## 解法
59+
60+
<!-- 这里可写通用的实现逻辑 -->
61+
62+
<!-- tabs:start -->
63+
64+
### **Python3**
65+
66+
<!-- 这里可写当前语言的特殊实现逻辑 -->
67+
68+
```python
69+
70+
```
71+
72+
### **Java**
73+
74+
<!-- 这里可写当前语言的特殊实现逻辑 -->
75+
76+
```java
77+
78+
```
79+
80+
### **...**
81+
82+
```
83+
84+
```
85+
86+
<!-- tabs:end -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# [2023. Number of Pairs of Strings With Concatenation Equal to Target](https://leetcode.com/problems/number-of-pairs-of-strings-with-concatenation-equal-to-target)
2+
3+
[中文文档](/solution/2000-2099/2023.Number%20of%20Pairs%20of%20Strings%20With%20Concatenation%20Equal%20to%20Target/README.md)
4+
5+
## Description
6+
7+
<p>Given an array of <strong>digit</strong> strings <code>nums</code> and a <strong>digit</strong> string <code>target</code>, return <em>the number of pairs of indices </em><code>(i, j)</code><em> (where </em><code>i != j</code><em>) such that the <strong>concatenation</strong> of </em><code>nums[i] + nums[j]</code><em> equals </em><code>target</code>.</p>
8+
9+
<p>&nbsp;</p>
10+
<p><strong>Example 1:</strong></p>
11+
12+
<pre>
13+
<strong>Input:</strong> nums = [&quot;777&quot;,&quot;7&quot;,&quot;77&quot;,&quot;77&quot;], target = &quot;7777&quot;
14+
<strong>Output:</strong> 4
15+
<strong>Explanation:</strong> Valid pairs are:
16+
- (0, 1): &quot;777&quot; + &quot;7&quot;
17+
- (1, 0): &quot;7&quot; + &quot;777&quot;
18+
- (2, 3): &quot;77&quot; + &quot;77&quot;
19+
- (3, 2): &quot;77&quot; + &quot;77&quot;
20+
</pre>
21+
22+
<p><strong>Example 2:</strong></p>
23+
24+
<pre>
25+
<strong>Input:</strong> nums = [&quot;123&quot;,&quot;4&quot;,&quot;12&quot;,&quot;34&quot;], target = &quot;1234&quot;
26+
<strong>Output:</strong> 2
27+
<strong>Explanation:</strong> Valid pairs are:
28+
- (0, 1): &quot;123&quot; + &quot;4&quot;
29+
- (2, 3): &quot;12&quot; + &quot;34&quot;
30+
</pre>
31+
32+
<p><strong>Example 3:</strong></p>
33+
34+
<pre>
35+
<strong>Input:</strong> nums = [&quot;1&quot;,&quot;1&quot;,&quot;1&quot;], target = &quot;11&quot;
36+
<strong>Output:</strong> 6
37+
<strong>Explanation:</strong> Valid pairs are:
38+
- (0, 1): &quot;1&quot; + &quot;1&quot;
39+
- (1, 0): &quot;1&quot; + &quot;1&quot;
40+
- (0, 2): &quot;1&quot; + &quot;1&quot;
41+
- (2, 0): &quot;1&quot; + &quot;1&quot;
42+
- (1, 2): &quot;1&quot; + &quot;1&quot;
43+
- (2, 1): &quot;1&quot; + &quot;1&quot;
44+
</pre>
45+
46+
<p>&nbsp;</p>
47+
<p><strong>Constraints:</strong></p>
48+
49+
<ul>
50+
<li><code>2 &lt;= nums.length &lt;= 100</code></li>
51+
<li><code>1 &lt;= nums[i].length &lt;= 100</code></li>
52+
<li><code>2 &lt;= target.length &lt;= 100</code></li>
53+
<li><code>nums[i]</code> and <code>target</code> consist of digits.</li>
54+
<li><code>nums[i]</code> and <code>target</code> do not have leading zeros.</li>
55+
</ul>
56+
57+
## Solutions
58+
59+
<!-- tabs:start -->
60+
61+
### **Python3**
62+
63+
```python
64+
65+
```
66+
67+
### **Java**
68+
69+
```java
70+
71+
```
72+
73+
### **...**
74+
75+
```
76+
77+
```
78+
79+
<!-- tabs:end -->

0 commit comments

Comments
 (0)