Skip to content

Commit ec60736

Browse files
committed
feat: add solutions to lc problem: No.1885
No.1885.Count Pairs in Two Arrays
1 parent f596a25 commit ec60736

File tree

30 files changed

+2628
-2380
lines changed

30 files changed

+2628
-2380
lines changed

basic/sorting/QuickSort/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public class Main {
113113
System.out.print(nums[i] + " ");
114114
}
115115
}
116-
116+
117117
public static void quickSort(int[] nums, int left, int right) {
118118
if (left >= right) {
119119
return;

lcci/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
快速搜索题号、题解、标签等,请善用 <kbd>Control</kbd>+<kbd>F</kbd>(或者 <kbd>Command</kbd>+<kbd>F</kbd>)。
1212

13-
| 题号 | 题解 | 标签 | 难度 |
14-
| ------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | --------------------------------------------- | ---- |
13+
| 题号 | 题解 | 标签 | 难度 |
14+
| --------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | --------------------------------------------- | ---- |
1515
| [01.01](https://leetcode.cn/problems/is-unique-lcci) | [判定字符是否唯一](/lcci/01.01.Is%20Unique/README.md) | `数组` | 简单 |
1616
| [01.02](https://leetcode.cn/problems/check-permutation-lcci) | [判定是否互为字符重排](/lcci/01.02.Check%20Permutation/README.md) | `数组`,`字符串` | 简单 |
1717
| [01.03](https://leetcode.cn/problems/string-to-url-lcci) | [URL 化](/lcci/01.03.String%20to%20URL/README.md) | `字符串` | 简单 |

lcci/README_EN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ _Cracking the Coding Interview, 6th Edition_ is here to help you through this pr
88

99
Press <kbd>Control</kbd>+<kbd>F</kbd>(or <kbd>Command</kbd>+<kbd>F</kbd> on the Mac) to search anything you want.
1010

11-
| # | Solution | Tag | Difficulty |
12-
| ------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ | ---------- |
11+
| # | Solution | Tag | Difficulty |
12+
| --------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ | ---------- |
1313
| [01.01](https://leetcode.cn/problems/is-unique-lcci) | [Is Unique](/lcci/01.01.Is%20Unique/README_EN.md) | `Array` | Easy |
1414
| [01.02](https://leetcode.cn/problems/check-permutation-lcci) | [Check Permutation](/lcci/01.02.Check%20Permutation/README_EN.md) | `Array`,`String` | Easy |
1515
| [01.03](https://leetcode.cn/problems/string-to-url-lcci) | [String to URL](/lcci/01.03.String%20to%20URL/README_EN.md) | `String` | Easy |

lcof/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
快速搜索题号、题解、标签等,请善用 <kbd>Control</kbd>+<kbd>F</kbd>(或者 <kbd>Command</kbd>+<kbd>F</kbd>)。
1414

15-
| 题号 | 题解 | 标签 | 难度 |
16-
| -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | ---- |
15+
| 题号 | 题解 | 标签 | 难度 |
16+
| ---------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | ---- |
1717
| [03](https://leetcode.cn/problems/shu-zu-zhong-zhong-fu-de-shu-zi-lcof) | [数组中重复的数字](/lcof/%E9%9D%A2%E8%AF%95%E9%A2%9803.%20%E6%95%B0%E7%BB%84%E4%B8%AD%E9%87%8D%E5%A4%8D%E7%9A%84%E6%95%B0%E5%AD%97/README.md) | `数组`,`哈希表` | 简单 |
1818
| [04](https://leetcode.cn/problems/er-wei-shu-zu-zhong-de-cha-zhao-lcof) | [二维数组中的查找](/lcof/%E9%9D%A2%E8%AF%95%E9%A2%9804.%20%E4%BA%8C%E7%BB%B4%E6%95%B0%E7%BB%84%E4%B8%AD%E7%9A%84%E6%9F%A5%E6%89%BE/README.md) | `数组`,`双指针` | 中等 |
1919
| [05](https://leetcode.cn/problems/ti-huan-kong-ge-lcof) | [替换空格](/lcof/%E9%9D%A2%E8%AF%95%E9%A2%9805.%20%E6%9B%BF%E6%8D%A2%E7%A9%BA%E6%A0%BC/README.md) | | 简单 |

lcof2/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
快速搜索题号、题解、标签等,请善用 <kbd>Control</kbd>+<kbd>F</kbd>(或者 <kbd>Command</kbd>+<kbd>F</kbd>)。
1212

13-
| 题号 | 题解 | 标签 | 难度 | 备注 |
14-
| ---------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- | ---- | ---- |
13+
| 题号 | 题解 | 标签 | 难度 | 备注 |
14+
| ------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- | ---- | ---- |
1515
| [001](https://leetcode.cn/problems/xoh6Oh) | [ 整数除法](/lcof2/%E5%89%91%E6%8C%87%20Offer%20II%20001.%20%E6%95%B4%E6%95%B0%E9%99%A4%E6%B3%95/README.md) | `数学` | 简单 |
1616
| [002](https://leetcode.cn/problems/JFETK5) | [ 二进制加法](/lcof2/%E5%89%91%E6%8C%87%20Offer%20II%20002.%20%E4%BA%8C%E8%BF%9B%E5%88%B6%E5%8A%A0%E6%B3%95/README.md) | `位运算`,`数学`,`字符串`,`模拟` | 简单 |
1717
| [003](https://leetcode.cn/problems/w3tCBm) | [ 前 n 个数字二进制中 1 的个数](/lcof2/%E5%89%91%E6%8C%87%20Offer%20II%20003.%20%E5%89%8D%20n%20%E4%B8%AA%E6%95%B0%E5%AD%97%E4%BA%8C%E8%BF%9B%E5%88%B6%E4%B8%AD%201%20%E7%9A%84%E4%B8%AA%E6%95%B0/README.md) | `位运算`,`动态规划` | 简单 |

lcp/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
快速搜索题号、题解、标签等,请善用 <kbd>Control</kbd>+<kbd>F</kbd>(或者 <kbd>Command</kbd>+<kbd>F</kbd>)。
88

9-
| 题号 | 题解 | 标签 | 难度 | 备注 |
10-
| ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------- | ---- | ---- |
9+
| 题号 | 题解 | 标签 | 难度 | 备注 |
10+
| -------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------- | ---- | ---- |
1111
| [LCP 01](https://leetcode.cn/problems/guess-numbers) | [ 猜数字](/lcp/LCP%2001.%20%E7%8C%9C%E6%95%B0%E5%AD%97/README.md) | `数组` | 简单 |
1212
| [LCP 02](https://leetcode.cn/problems/deep-dark-fraction) | [ 分式化简](/lcp/LCP%2002.%20%E5%88%86%E5%BC%8F%E5%8C%96%E7%AE%80/README.md) | `数组`,`数学`,`数论`,`模拟` | 简单 |
1313
| [LCP 03](https://leetcode.cn/problems/programmable-robot) | [ 机器人大冒险](/lcp/LCP%2003.%20%E6%9C%BA%E5%99%A8%E4%BA%BA%E5%A4%A7%E5%86%92%E9%99%A9/README.md) | `数组`,`哈希表`,`模拟` | 中等 |

lcs/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
快速搜索题号、题解、标签等,请善用 <kbd>Control</kbd>+<kbd>F</kbd>(或者 <kbd>Command</kbd>+<kbd>F</kbd>)。
88

9-
| 题号 | 题解 | 标签 | 难度 | 备注 |
10-
| -------------------------------------------------- | -------------------------------------------------------------------------------------------------- | ---------------------------------------------------- | ---- | ---- |
9+
| 题号 | 题解 | 标签 | 难度 | 备注 |
10+
| ---------------------------------------------- | -------------------------------------------------------------------------------------------------- | ---------------------------------------------------- | ---- | ---- |
1111
| [LCS 01](https://leetcode.cn/problems/Ju9Xwi/) | [ 下载插件](/lcs/LCS%2001.%20%E4%B8%8B%E8%BD%BD%E6%8F%92%E4%BB%B6/README.md) | `数学`,`动态规划` | 简单 |
1212
| [LCS 02](https://leetcode.cn/problems/WqXACV/) | [ 完成一半题目](/lcs/LCS%2002.%20%E5%AE%8C%E6%88%90%E4%B8%80%E5%8D%8A%E9%A2%98%E7%9B%AE/README.md) | `贪心`,`数组`,`哈希表`,`排序` | 简单 |
1313
| [LCS 03](https://leetcode.cn/problems/YesdPw/) | [ 主题空间](/lcs/LCS%2003.%20%E4%B8%BB%E9%A2%98%E7%A9%BA%E9%97%B4/README.md) | `深度优先搜索`,`广度优先搜索`,`并查集`,`数组`,`矩阵` | 中等 |
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
function coinChange(coins: number[], amount: number): number {
2-
let dp = new Array(amount + 1).fill(amount + 1);
3-
dp[0] = 0;
4-
for (const coin of coins) {
5-
for (let j = coin; j <= amount; ++j) {
6-
dp[j] = Math.min(dp[j], dp[j - coin] + 1);
7-
}
8-
}
9-
return dp[amount] > amount ? -1 : dp[amount];
10-
}
1+
function coinChange(coins: number[], amount: number): number {
2+
let dp = new Array(amount + 1).fill(amount + 1);
3+
dp[0] = 0;
4+
for (const coin of coins) {
5+
for (let j = coin; j <= amount; ++j) {
6+
dp[j] = Math.min(dp[j], dp[j - coin] + 1);
7+
}
8+
}
9+
return dp[amount] > amount ? -1 : dp[amount];
10+
}

solution/0300-0399/0336.Palindrome Pairs/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
<strong>输出:</strong>[[0,1],[1,0]]
3333
</pre>
3434

35-
36-
3735
<p><strong>提示:</strong></p>
3836

3937
<ul>

solution/0500-0599/0554.Brick Wall/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
<strong>输出:</strong>3
2929
</pre>
3030

31-
32-
3331
<p><strong>提示:</strong></p>
3432

3533
<ul>

0 commit comments

Comments
 (0)