Skip to content

Commit d0b941d

Browse files
authored
style: format code (doocs#1030)
1 parent d3f7728 commit d0b941d

File tree

51 files changed

+67
-59
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+67
-59
lines changed

.github/workflows/prettier.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,20 @@ jobs:
88
prettier:
99
runs-on: ubuntu-latest
1010

11+
permissions:
12+
contents: write
13+
1114
steps:
1215
- name: Checkout
1316
uses: actions/checkout@v3
1417
with:
1518
ref: ${{ github.head_ref }}
19+
repository: ${{ github.event.pull_request.head.repo.full_name }}
1620
fetch-depth: 0
1721

1822
- name: Prettify code
1923
uses: creyD/prettier_action@v4.3
2024
with:
2125
prettier_options: --write **/*.{js,ts,md}
22-
only_changed: True
26+
only_changed: true
2327
commit_message: "style: format code with prettier"

solution/0000-0099/0048.Rotate Image/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class Solution:
7676
class Solution {
7777
public void rotate(int[][] matrix) {
7878
int n = matrix.length;
79-
for (int i = 0; i<n> > 1; ++i) {
79+
for (int i = 0; i < n >> 1; ++i) {
8080
for (int j = 0; j < n; ++j) {
8181
int t = matrix[i][j];
8282
matrix[i][j] = matrix[n - i - 1][j];

solution/0000-0099/0048.Rotate Image/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class Solution:
6464
class Solution {
6565
public void rotate(int[][] matrix) {
6666
int n = matrix.length;
67-
for (int i = 0; i<n> > 1; ++i) {
67+
for (int i = 0; i < n >> 1; ++i) {
6868
for (int j = 0; j < n; ++j) {
6969
int t = matrix[i][j];
7070
matrix[i][j] = matrix[n - i - 1][j];

solution/0000-0099/0048.Rotate Image/Solution.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ class Solution {
22
public:
33
void rotate(vector<vector<int>>& matrix) {
44
int n = matrix.size();
5-
for (int i = 0; i<n> > 1; ++i) {
5+
for (int i = 0; i < n >> 1; ++i) {
66
for (int j = 0; j < n; ++j) {
77
swap(matrix[i][j], matrix[n - i - 1][j]);
88
}

solution/0000-0099/0048.Rotate Image/Solution.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class Solution {
22
public void rotate(int[][] matrix) {
33
int n = matrix.length;
4-
for (int i = 0; i<n> > 1; ++i) {
4+
for (int i = 0; i < n >> 1; ++i) {
55
for (int j = 0; j < n; ++j) {
66
int t = matrix[i][j];
77
matrix[i][j] = matrix[n - i - 1][j];

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ int singleNumber(int* nums, int numsSize) {
77
count++;
88
}
99
}
10-
ans |= (uint)(count % 3) << i;
10+
ans |= (uint) (count % 3) << i;
1111
}
1212
return ans;
1313
}

solution/0300-0399/0374.Guess Number Higher or Lower/Solution.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/**
22
* Forward declaration of guess API.
33
* @param num your guess
44
* @return -1 if num is lower than the guess number

solution/0400-0499/0427.Construct Quad Tree/Solution.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Node {
88
Node* topRight;
99
Node* bottomLeft;
1010
Node* bottomRight;
11-
11+
1212
Node() {
1313
val = false;
1414
isLeaf = false;
@@ -17,7 +17,7 @@ class Node {
1717
bottomLeft = NULL;
1818
bottomRight = NULL;
1919
}
20-
20+
2121
Node(bool _val, bool _isLeaf) {
2222
val = _val;
2323
isLeaf = _isLeaf;
@@ -26,7 +26,7 @@ class Node {
2626
bottomLeft = NULL;
2727
bottomRight = NULL;
2828
}
29-
29+
3030
Node(bool _val, bool _isLeaf, Node* _topLeft, Node* _topRight, Node* _bottomLeft, Node* _bottomRight) {
3131
val = _val;
3232
isLeaf = _isLeaf;

solution/0500-0599/0544.Output Contest Matches/Solution.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class Solution {
44
vector<string> team(n);
55
for (int i = 0; i < n; ++i) team[i] = to_string(i + 1);
66
for (; n > 1; n >>= 1) {
7-
for (int i = 0; i<n> > 1; ++i) {
7+
for (int i = 0; i < n >> 1; ++i) {
88
team[i] = "(" + team[i] + "," + team[n - 1 - i] + ")";
99
}
1010
}

solution/0500-0599/0558.Logical OR of Two Binary Grids Represented as Quad-Trees/Solution.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Node {
88
Node* topRight;
99
Node* bottomLeft;
1010
Node* bottomRight;
11-
11+
1212
Node() {
1313
val = false;
1414
isLeaf = false;
@@ -17,7 +17,7 @@ class Node {
1717
bottomLeft = NULL;
1818
bottomRight = NULL;
1919
}
20-
20+
2121
Node(bool _val, bool _isLeaf) {
2222
val = _val;
2323
isLeaf = _isLeaf;
@@ -26,7 +26,7 @@ class Node {
2626
bottomLeft = NULL;
2727
bottomRight = NULL;
2828
}
29-
29+
3030
Node(bool _val, bool _isLeaf, Node* _topLeft, Node* _topRight, Node* _bottomLeft, Node* _bottomRight) {
3131
val = _val;
3232
isLeaf = _isLeaf;

solution/0900-0999/0907.Sum of Subarray Minimums/Solution.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Solution {
2121
}
2222
ll ans = 0;
2323
for (int i = 0; i < n; ++i) {
24-
ans += (ll)(i - left[i]) * (right[i] - i) * arr[i] % mod;
24+
ans += (ll) (i - left[i]) * (right[i] - i) * arr[i] % mod;
2525
ans %= mod;
2626
}
2727
return ans;

solution/1100-1199/1166.Design File System/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ class FileSystem {
180180
private Trie trie = new Trie(-1);
181181

182182
public FileSystem() {
183-
184183
}
185184

186185
public boolean createPath(String path, int value) {

solution/1100-1199/1166.Design File System/README_EN.md

-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ class FileSystem {
155155
private Trie trie = new Trie(-1);
156156

157157
public FileSystem() {
158-
159158
}
160159

161160
public boolean createPath(String path, int value) {

solution/1100-1199/1166.Design File System/Solution.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ class Trie {
3737
return node->v;
3838
}
3939

40-
4140
private:
4241
vector<string> split(string& s, char delim) {
4342
stringstream ss(s);
@@ -55,11 +54,11 @@ class FileSystem {
5554
FileSystem() {
5655
trie = new Trie(-1);
5756
}
58-
57+
5958
bool createPath(string path, int value) {
6059
return trie->insert(path, value);
6160
}
62-
61+
6362
int get(string path) {
6463
return trie->search(path);
6564
}

solution/1100-1199/1166.Design File System/Solution.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,12 @@ class FileSystem {
4141
private Trie trie = new Trie(-1);
4242

4343
public FileSystem() {
44-
4544
}
46-
45+
4746
public boolean createPath(String path, int value) {
4847
return trie.insert(path, value);
4948
}
50-
49+
5150
public int get(String path) {
5251
return trie.search(path);
5352
}

solution/1100-1199/1168.Optimize Water Distribution in a Village/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class Solution {
121121
nums[j++] = pipe;
122122
}
123123
for (int i = 0; i < n; ++i) {
124-
nums[j++] = new int[]{0, i + 1, wells[i]};
124+
nums[j++] = new int[] {0, i + 1, wells[i]};
125125
}
126126
Arrays.sort(nums, (a, b) -> a[2] - b[2]);
127127
p = new int[n + 1];

solution/1100-1199/1168.Optimize Water Distribution in a Village/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class Solution {
103103
nums[j++] = pipe;
104104
}
105105
for (int i = 0; i < n; ++i) {
106-
nums[j++] = new int[]{0, i + 1, wells[i]};
106+
nums[j++] = new int[] {0, i + 1, wells[i]};
107107
}
108108
Arrays.sort(nums, (a, b) -> a[2] - b[2]);
109109
p = new int[n + 1];

solution/1100-1199/1168.Optimize Water Distribution in a Village/Solution.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public int minCostToSupplyWater(int n, int[] wells, int[][] pipes) {
88
nums[j++] = pipe;
99
}
1010
for (int i = 0; i < n; ++i) {
11-
nums[j++] = new int[]{0, i + 1, wells[i]};
11+
nums[j++] = new int[] {0, i + 1, wells[i]};
1212
}
1313
Arrays.sort(nums, (a, b) -> a[2] - b[2]);
1414
p = new int[n + 1];

solution/1100-1199/1181.Before and After Puzzle/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class Solution {
106106
var ps = new String[n][];
107107
for (int i = 0; i < n; ++i) {
108108
var ws = phrases[i].split(" ");
109-
ps[i] = new String[]{ws[0], ws[ws.length - 1]};
109+
ps[i] = new String[] {ws[0], ws[ws.length - 1]};
110110
}
111111
Set<String> s = new HashSet<>();
112112
for (int i = 0; i < n; ++i) {

solution/1100-1199/1181.Before and After Puzzle/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class Solution {
8787
var ps = new String[n][];
8888
for (int i = 0; i < n; ++i) {
8989
var ws = phrases[i].split(" ");
90-
ps[i] = new String[]{ws[0], ws[ws.length - 1]};
90+
ps[i] = new String[] {ws[0], ws[ws.length - 1]};
9191
}
9292
Set<String> s = new HashSet<>();
9393
for (int i = 0; i < n; ++i) {

solution/1100-1199/1181.Before and After Puzzle/Solution.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ public List<String> beforeAndAfterPuzzles(String[] phrases) {
44
var ps = new String[n][];
55
for (int i = 0; i < n; ++i) {
66
var ws = phrases[i].split(" ");
7-
ps[i] = new String[]{ws[0], ws[ws.length - 1]};
7+
ps[i] = new String[] {ws[0], ws[ws.length - 1]};
88
}
99
Set<String> s = new HashSet<>();
1010
for (int i = 0; i < n; ++i) {

solution/1100-1199/1188.Design Bounded Blocking Queue/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class BoundedBlockingQueue {
148148
}
149149

150150
public int dequeue() throws InterruptedException {
151-
s2.acquire();;
151+
s2.acquire();
152152
int ans = q.poll();
153153
s1.release();
154154
return ans;

solution/1100-1199/1188.Design Bounded Blocking Queue/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class BoundedBlockingQueue {
140140
}
141141

142142
public int dequeue() throws InterruptedException {
143-
s2.acquire();;
143+
s2.acquire();
144144
int ans = q.poll();
145145
s1.release();
146146
return ans;

solution/1100-1199/1188.Design Bounded Blocking Queue/Solution.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public void enqueue(int element) throws InterruptedException {
1515
}
1616

1717
public int dequeue() throws InterruptedException {
18-
s2.acquire();;
18+
s2.acquire();
1919
int ans = q.poll();
2020
s1.release();
2121
return ans;

solution/1400-1499/1401.Circle and Rectangle Overlapping/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ class Solution:
9494

9595
```java
9696
class Solution {
97-
public boolean checkOverlap(int radius, int xCenter, int yCenter, int x1, int y1, int x2, int y2) {
97+
public boolean checkOverlap(
98+
int radius, int xCenter, int yCenter, int x1, int y1, int x2, int y2) {
9899
int a = f(x1, x2, xCenter);
99100
int b = f(y1, y2, yCenter);
100101
return a * a + b * b <= radius * radius;

solution/1400-1499/1401.Circle and Rectangle Overlapping/README_EN.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ class Solution:
6464

6565
```java
6666
class Solution {
67-
public boolean checkOverlap(int radius, int xCenter, int yCenter, int x1, int y1, int x2, int y2) {
67+
public boolean checkOverlap(
68+
int radius, int xCenter, int yCenter, int x1, int y1, int x2, int y2) {
6869
int a = f(x1, x2, xCenter);
6970
int b = f(y1, y2, yCenter);
7071
return a * a + b * b <= radius * radius;

solution/1400-1499/1401.Circle and Rectangle Overlapping/Solution.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
class Solution {
2-
public boolean checkOverlap(int radius, int xCenter, int yCenter, int x1, int y1, int x2, int y2) {
2+
public boolean checkOverlap(
3+
int radius, int xCenter, int yCenter, int x1, int y1, int x2, int y2) {
34
int a = f(x1, x2, xCenter);
45
int b = f(y1, y2, yCenter);
56
return a * a + b * b <= radius * radius;

solution/1500-1599/1533.Find the Index of the Large Integer/Solution.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* // You should not implement it, or speculate about its implementation
44
* class ArrayReader {
55
* public:
6-
* // Compares the sum of arr[l..r] with the sum of arr[x..y]
6+
* // Compares the sum of arr[l..r] with the sum of arr[x..y]
77
* // return 1 if sum(arr[l..r]) > sum(arr[x..y])
88
* // return 0 if sum(arr[l..r]) == sum(arr[x..y])
99
* // return -1 if sum(arr[l..r]) < sum(arr[x..y])

solution/1600-1699/1618.Maximum Font to Fit a Sentence in a Screen/Solution.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* public:
66
* // Return the width of char ch when fontSize is used.
77
* int getWidth(int fontSize, char ch);
8-
*
8+
*
99
* // Return Height of any char when fontSize is used.
1010
* int getHeight(int fontSize)
1111
* };

solution/1600-1699/1628.Design an Expression Tree With Evaluate Function/Solution.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class MyNode : public Node {
4040

4141
/**
4242
* This is the TreeBuilder class.
43-
* You can treat it as the driver code that takes the postinfix input
43+
* You can treat it as the driver code that takes the postinfix input
4444
* and returns the expression tree represnting it as a Node.
4545
*/
4646

solution/1600-1699/1674.Minimum Moves to Make Array Complementary/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class Solution {
123123
public int minMoves(int[] nums, int limit) {
124124
int n = nums.length;
125125
int[] d = new int[limit * 2 + 2];
126-
for (int i = 0; i<n> > 1; ++i) {
126+
for (int i = 0; i < n >> 1; ++i) {
127127
int a = Math.min(nums[i], nums[n - i - 1]);
128128
int b = Math.max(nums[i], nums[n - i - 1]);
129129

solution/1600-1699/1674.Minimum Moves to Make Array Complementary/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class Solution {
8989
public int minMoves(int[] nums, int limit) {
9090
int n = nums.length;
9191
int[] d = new int[limit * 2 + 2];
92-
for (int i = 0; i<n> > 1; ++i) {
92+
for (int i = 0; i < n >> 1; ++i) {
9393
int a = Math.min(nums[i], nums[n - i - 1]);
9494
int b = Math.max(nums[i], nums[n - i - 1]);
9595

solution/1600-1699/1674.Minimum Moves to Make Array Complementary/Solution.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class Solution {
33
int minMoves(vector<int>& nums, int limit) {
44
int n = nums.size();
55
vector<int> d(limit * 2 + 2);
6-
for (int i = 0; i<n> > 1; ++i) {
6+
for (int i = 0; i < n >> 1; ++i) {
77
int a = min(nums[i], nums[n - i - 1]);
88
int b = max(nums[i], nums[n - i - 1]);
99

solution/1600-1699/1674.Minimum Moves to Make Array Complementary/Solution.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ class Solution {
22
public int minMoves(int[] nums, int limit) {
33
int n = nums.length;
44
int[] d = new int[limit * 2 + 2];
5-
for (int i = 0; i<n> > 1; ++i) {
5+
for (int i = 0; i < n >> 1; ++i) {
66
int a = Math.min(nums[i], nums[n - i - 1]);
77
int b = Math.max(nums[i], nums[n - i - 1]);
88

solution/1700-1799/1773.Count Items Matching a Rule/Solution.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
int countMatches(char*** items, int itemsSize, int* itemsColSize, char* ruleKey, char* ruleValue) {
2-
int k = strcmp(ruleKey, "type") == 0 ? 0 : strcmp(ruleKey, "color") == 0 ? 1 : 2;
2+
int k = strcmp(ruleKey, "type") == 0 ? 0 : strcmp(ruleKey, "color") == 0 ? 1
3+
: 2;
34
int res = 0;
45
for (int i = 0; i < itemsSize; i++) {
56
if (strcmp(items[i][k], ruleValue) == 0) {

solution/2100-2199/2164.Sort Even and Odd Indices Independently/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class Solution {
8989
int n = nums.length;
9090
int[] a = new int[(n + 1) >> 1];
9191
int[] b = new int[n >> 1];
92-
for (int i = 0, j = 0; j<n> > 1; i += 2, ++j) {
92+
for (int i = 0, j = 0; j < n >> 1; i += 2, ++j) {
9393
a[j] = nums[i];
9494
b[j] = nums[i + 1];
9595
}

solution/2100-2199/2164.Sort Even and Odd Indices Independently/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class Solution {
7979
int n = nums.length;
8080
int[] a = new int[(n + 1) >> 1];
8181
int[] b = new int[n >> 1];
82-
for (int i = 0, j = 0; j<n> > 1; i += 2, ++j) {
82+
for (int i = 0, j = 0; j < n >> 1; i += 2, ++j) {
8383
a[j] = nums[i];
8484
b[j] = nums[i + 1];
8585
}

0 commit comments

Comments
 (0)