Skip to content

Commit 5ab2803

Browse files
committed
feat: update lc problems
1 parent 00ac913 commit 5ab2803

File tree

40 files changed

+122
-129
lines changed

40 files changed

+122
-129
lines changed

solution/0000-0099/0001.Two Sum/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class Solution:
8888
class Solution {
8989
public int[] twoSum(int[] nums, int target) {
9090
Map<Integer, Integer> m = new HashMap<>();
91-
for (int i = 0; ; ++i) {
91+
for (int i = 0;; ++i) {
9292
int x = nums[i];
9393
int y = target - x;
9494
if (m.containsKey(y)) {

solution/0000-0099/0001.Two Sum/README_EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class Solution:
6969
class Solution {
7070
public int[] twoSum(int[] nums, int target) {
7171
Map<Integer, Integer> m = new HashMap<>();
72-
for (int i = 0; ; ++i) {
72+
for (int i = 0;; ++i) {
7373
int x = nums[i];
7474
int y = target - x;
7575
if (m.containsKey(y)) {

solution/0000-0099/0001.Two Sum/Solution.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ class Solution {
22
public:
33
vector<int> twoSum(vector<int>& nums, int target) {
44
unordered_map<int, int> m;
5-
for (int i = 0; ; ++i) {
5+
for (int i = 0;; ++i) {
66
int x = nums[i];
77
int y = target - x;
88
if (m.count(y)) {

solution/0000-0099/0001.Two Sum/Solution.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class Solution {
22
public int[] twoSum(int[] nums, int target) {
33
Map<Integer, Integer> m = new HashMap<>();
4-
for (int i = 0; ; ++i) {
4+
for (int i = 0;; ++i) {
55
int x = nums[i];
66
int y = target - x;
77
if (m.containsKey(y)) {

solution/0100-0199/0136.Single Number/Solution.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
int singleNumber(int *nums, int numsSize) {
1+
int singleNumber(int* nums, int numsSize) {
22
int ans = 0;
33
for (int i = 0; i < numsSize; i++) {
44
ans ^= nums[i];

solution/0100-0199/0137.Single Number II/Solution.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
int singleNumber(int *nums, int numsSize) {
1+
int singleNumber(int* nums, int numsSize) {
22
int ans = 0;
33
for (int i = 0; i < 32; i++) {
44
int count = 0;

solution/0100-0199/0182.Duplicate Emails/README_EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Each row of this table contains an email. The emails will not contain uppercase
1919

2020
<p>&nbsp;</p>
2121

22-
<p>Write an SQL query to report all the duplicate emails.</p>
22+
<p>Write an SQL query to report all the duplicate emails. Note that it&#39;s guaranteed that the email&nbsp;field is not NULL.</p>
2323

2424
<p>Return the result table in <strong>any order</strong>.</p>
2525

solution/0400-0499/0410.Split Array Largest Sum/Solution.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public int splitArray(int[] nums, int k) {
1515
}
1616
return left;
1717
}
18-
18+
1919
private boolean check(int[] nums, int mx, int k) {
2020
int s = 1 << 30, cnt = 0;
2121
for (int x : nums) {

solution/0400-0499/0465.Optimal Account Balancing/README.md

Lines changed: 27 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,54 +6,46 @@
66

77
<!-- 这里写题目描述 -->
88

9-
<p>一群朋友在度假期间会相互借钱。比如说,小爱同学支付了小新同学的午餐共计 10 美元。如果小明同学支付了小爱同学的出租车钱共计 5 美元。我们可以用一个三元组 (x, y, z) 表示一次交易,表示 x 借给 y 共计 z 美元。用 0, 1, 2 表示小爱同学、小新同学和小明同学(0, 1, 2 为人的标号),上述交易可以表示为 <code>[[0, 1, 10], [2, 0, 5]]</code>。</p>
9+
<p>给你一个表示交易的数组 <code>transactions</code> ,其中 <code>transactions[i] = [from<sub>i</sub>, to<sub>i</sub>, amount<sub>i</sub>]</code> 表示 <code>ID = from<sub>i</sub></code> 的人给&nbsp;<code>ID = to<sub>i</sub></code> 的人共计 <code>amount<sub>i</sub> $</code> 。</p>
1010

11-
<p>给定一群人之间的交易信息列表,计算能够还清所有债务的最小次数。</p>
12-
13-
<p><strong>注意:</strong></p>
14-
15-
<ol>
16-
<li>一次交易会以三元组 (x, y, z) 表示,并有&nbsp;<code>x &ne; y</code>&nbsp;且&nbsp;<code>z &gt; 0</code>。</li>
17-
<li>人的标号可能不是按顺序的,例如标号可能为 0, 1, 2 也可能为 0, 2, 6。</li>
18-
</ol>
11+
<p>请你计算并返回还清所有债务的最小交易笔数。</p>
1912

2013
<p>&nbsp;</p>
2114

22-
<p><strong>示例 1:</strong></p>
15+
<p><strong class="example">示例 1:</strong></p>
2316

24-
<pre><strong>输入:</strong>
25-
[[0,1,10], [2,0,5]]
17+
<pre>
18+
<strong>输入:</strong>transactions = [[0,1,10],[2,0,5]]
19+
<strong>输出:</strong>2
20+
<strong>解释:</strong>
21+
#0 给 #1 $10 。
22+
#2 给 #0 $5 。
23+
需要进行两笔交易。一种结清债务的方式是 #1 给 #0 和 #2 各 $5 。</pre>
2624

27-
<strong>输出:</strong>
28-
2
25+
<p><strong class="example">示例 2:</strong></p>
2926

27+
<pre>
28+
<strong>输入:</strong>transactions = [[0,1,10],[1,0,1],[1,2,5],[2,0,5]]
29+
<strong>输出:</strong>1
3030
<strong>解释:</strong>
31-
人 #0 给人 #1 共计 10 美元。
32-
人 #2 给人 #0 共计 5 美元。
33-
34-
需要两次交易。一种方式是人 #1 分别给人 #0 和人 #2 各 5 美元。
31+
#0 给 #1 $10 。
32+
#1 给 #0 $1 。
33+
#1 给 #2 $5 。
34+
#2 给 #0 $5 。
35+
因此,#1 只需要给 #0 $4 ,所有的债务即可还清。
3536
</pre>
3637

3738
<p>&nbsp;</p>
3839

39-
<p><strong>示例 2:</strong></p>
40-
41-
<pre><strong>输入:</strong>
42-
[[0,1,10], [1,0,1], [1,2,5], [2,0,5]]
43-
44-
<strong>输出:</strong>
45-
1
40+
<p><strong>提示:</strong></p>
4641

47-
<strong>解释:</strong>
48-
人 #0 给人 #1 共计 10 美元。Person #0 gave person #1 $10.
49-
人 #1 给人 #0 共计 1 美元。Person #1 gave person #0 $1.
50-
人 #1 给人 #2 共计 5 美元。Person #1 gave person #2 $5.
51-
人 #2 给人 #0 共计 5 美元。Person #2 gave person #0 $5.
52-
53-
因此,人 #1 需要给人 #0 共计 4 美元,所有的债务即可还清。
54-
</pre>
55-
56-
<p>&nbsp;</p>
42+
<ul>
43+
<li><code>1 &lt;= transactions.length &lt;= 8</code></li>
44+
<li><code>transactions[i].length == 3</code></li>
45+
<li><code>0 &lt;= from<sub>i</sub>, to<sub>i</sub> &lt; 12</code></li>
46+
<li><code>from<sub>i</sub> != to<sub>i</sub></code></li>
47+
<li><code>1 &lt;= amount<sub>i</sub> &lt;= 100</code></li>
48+
</ul>
5749

5850
## 解法
5951

solution/0800-0899/0831.Masking Personal Information/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,9 @@ class Solution {
166166
s = sb.toString();
167167
int cnt = s.length() - 10;
168168
String suf = "***-***-" + s.substring(s.length() - 4);
169-
return cnt == 0 ? suf : "+" + "*".repeat(cnt) + "-" + suf;
169+
return cnt == 0 ? suf
170+
: "+"
171+
+ "*".repeat(cnt) + "-" + suf;
170172
}
171173
}
172174
```

0 commit comments

Comments
 (0)