Skip to content

style: format code #1030

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,20 @@ jobs:
prettier:
runs-on: ubuntu-latest

permissions:
contents: write

steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: 0

- name: Prettify code
uses: creyD/prettier_action@v4.3
with:
prettier_options: --write **/*.{js,ts,md}
only_changed: True
only_changed: true
commit_message: "style: format code with prettier"
2 changes: 1 addition & 1 deletion solution/0000-0099/0048.Rotate Image/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class Solution:
class Solution {
public void rotate(int[][] matrix) {
int n = matrix.length;
for (int i = 0; i<n> > 1; ++i) {
for (int i = 0; i < n >> 1; ++i) {
for (int j = 0; j < n; ++j) {
int t = matrix[i][j];
matrix[i][j] = matrix[n - i - 1][j];
Expand Down
2 changes: 1 addition & 1 deletion solution/0000-0099/0048.Rotate Image/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class Solution:
class Solution {
public void rotate(int[][] matrix) {
int n = matrix.length;
for (int i = 0; i<n> > 1; ++i) {
for (int i = 0; i < n >> 1; ++i) {
for (int j = 0; j < n; ++j) {
int t = matrix[i][j];
matrix[i][j] = matrix[n - i - 1][j];
Expand Down
2 changes: 1 addition & 1 deletion solution/0000-0099/0048.Rotate Image/Solution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class Solution {
public:
void rotate(vector<vector<int>>& matrix) {
int n = matrix.size();
for (int i = 0; i<n> > 1; ++i) {
for (int i = 0; i < n >> 1; ++i) {
for (int j = 0; j < n; ++j) {
swap(matrix[i][j], matrix[n - i - 1][j]);
}
Expand Down
2 changes: 1 addition & 1 deletion solution/0000-0099/0048.Rotate Image/Solution.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Solution {
public void rotate(int[][] matrix) {
int n = matrix.length;
for (int i = 0; i<n> > 1; ++i) {
for (int i = 0; i < n >> 1; ++i) {
for (int j = 0; j < n; ++j) {
int t = matrix[i][j];
matrix[i][j] = matrix[n - i - 1][j];
Expand Down
2 changes: 1 addition & 1 deletion solution/0100-0199/0137.Single Number II/Solution.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ int singleNumber(int* nums, int numsSize) {
count++;
}
}
ans |= (uint)(count % 3) << i;
ans |= (uint) (count % 3) << i;
}
return ans;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/**
* Forward declaration of guess API.
* @param num your guess
* @return -1 if num is lower than the guess number
Expand Down
6 changes: 3 additions & 3 deletions solution/0400-0499/0427.Construct Quad Tree/Solution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Node {
Node* topRight;
Node* bottomLeft;
Node* bottomRight;

Node() {
val = false;
isLeaf = false;
Expand All @@ -17,7 +17,7 @@ class Node {
bottomLeft = NULL;
bottomRight = NULL;
}

Node(bool _val, bool _isLeaf) {
val = _val;
isLeaf = _isLeaf;
Expand All @@ -26,7 +26,7 @@ class Node {
bottomLeft = NULL;
bottomRight = NULL;
}

Node(bool _val, bool _isLeaf, Node* _topLeft, Node* _topRight, Node* _bottomLeft, Node* _bottomRight) {
val = _val;
isLeaf = _isLeaf;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Solution {
vector<string> team(n);
for (int i = 0; i < n; ++i) team[i] = to_string(i + 1);
for (; n > 1; n >>= 1) {
for (int i = 0; i<n> > 1; ++i) {
for (int i = 0; i < n >> 1; ++i) {
team[i] = "(" + team[i] + "," + team[n - 1 - i] + ")";
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Node {
Node* topRight;
Node* bottomLeft;
Node* bottomRight;

Node() {
val = false;
isLeaf = false;
Expand All @@ -17,7 +17,7 @@ class Node {
bottomLeft = NULL;
bottomRight = NULL;
}

Node(bool _val, bool _isLeaf) {
val = _val;
isLeaf = _isLeaf;
Expand All @@ -26,7 +26,7 @@ class Node {
bottomLeft = NULL;
bottomRight = NULL;
}

Node(bool _val, bool _isLeaf, Node* _topLeft, Node* _topRight, Node* _bottomLeft, Node* _bottomRight) {
val = _val;
isLeaf = _isLeaf;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Solution {
}
ll ans = 0;
for (int i = 0; i < n; ++i) {
ans += (ll)(i - left[i]) * (right[i] - i) * arr[i] % mod;
ans += (ll) (i - left[i]) * (right[i] - i) * arr[i] % mod;
ans %= mod;
}
return ans;
Expand Down
1 change: 0 additions & 1 deletion solution/1100-1199/1166.Design File System/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ class FileSystem {
private Trie trie = new Trie(-1);

public FileSystem() {

}

public boolean createPath(String path, int value) {
Expand Down
1 change: 0 additions & 1 deletion solution/1100-1199/1166.Design File System/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ class FileSystem {
private Trie trie = new Trie(-1);

public FileSystem() {

}

public boolean createPath(String path, int value) {
Expand Down
5 changes: 2 additions & 3 deletions solution/1100-1199/1166.Design File System/Solution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class Trie {
return node->v;
}


private:
vector<string> split(string& s, char delim) {
stringstream ss(s);
Expand All @@ -55,11 +54,11 @@ class FileSystem {
FileSystem() {
trie = new Trie(-1);
}

bool createPath(string path, int value) {
return trie->insert(path, value);
}

int get(string path) {
return trie->search(path);
}
Expand Down
5 changes: 2 additions & 3 deletions solution/1100-1199/1166.Design File System/Solution.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,12 @@ class FileSystem {
private Trie trie = new Trie(-1);

public FileSystem() {

}

public boolean createPath(String path, int value) {
return trie.insert(path, value);
}

public int get(String path) {
return trie.search(path);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class Solution {
nums[j++] = pipe;
}
for (int i = 0; i < n; ++i) {
nums[j++] = new int[]{0, i + 1, wells[i]};
nums[j++] = new int[] {0, i + 1, wells[i]};
}
Arrays.sort(nums, (a, b) -> a[2] - b[2]);
p = new int[n + 1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class Solution {
nums[j++] = pipe;
}
for (int i = 0; i < n; ++i) {
nums[j++] = new int[]{0, i + 1, wells[i]};
nums[j++] = new int[] {0, i + 1, wells[i]};
}
Arrays.sort(nums, (a, b) -> a[2] - b[2]);
p = new int[n + 1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public int minCostToSupplyWater(int n, int[] wells, int[][] pipes) {
nums[j++] = pipe;
}
for (int i = 0; i < n; ++i) {
nums[j++] = new int[]{0, i + 1, wells[i]};
nums[j++] = new int[] {0, i + 1, wells[i]};
}
Arrays.sort(nums, (a, b) -> a[2] - b[2]);
p = new int[n + 1];
Expand Down
2 changes: 1 addition & 1 deletion solution/1100-1199/1181.Before and After Puzzle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class Solution {
var ps = new String[n][];
for (int i = 0; i < n; ++i) {
var ws = phrases[i].split(" ");
ps[i] = new String[]{ws[0], ws[ws.length - 1]};
ps[i] = new String[] {ws[0], ws[ws.length - 1]};
}
Set<String> s = new HashSet<>();
for (int i = 0; i < n; ++i) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class Solution {
var ps = new String[n][];
for (int i = 0; i < n; ++i) {
var ws = phrases[i].split(" ");
ps[i] = new String[]{ws[0], ws[ws.length - 1]};
ps[i] = new String[] {ws[0], ws[ws.length - 1]};
}
Set<String> s = new HashSet<>();
for (int i = 0; i < n; ++i) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ public List<String> beforeAndAfterPuzzles(String[] phrases) {
var ps = new String[n][];
for (int i = 0; i < n; ++i) {
var ws = phrases[i].split(" ");
ps[i] = new String[]{ws[0], ws[ws.length - 1]};
ps[i] = new String[] {ws[0], ws[ws.length - 1]};
}
Set<String> s = new HashSet<>();
for (int i = 0; i < n; ++i) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class BoundedBlockingQueue {
}

public int dequeue() throws InterruptedException {
s2.acquire();;
s2.acquire();
int ans = q.poll();
s1.release();
return ans;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class BoundedBlockingQueue {
}

public int dequeue() throws InterruptedException {
s2.acquire();;
s2.acquire();
int ans = q.poll();
s1.release();
return ans;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public void enqueue(int element) throws InterruptedException {
}

public int dequeue() throws InterruptedException {
s2.acquire();;
s2.acquire();
int ans = q.poll();
s1.release();
return ans;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ class Solution:

```java
class Solution {
public boolean checkOverlap(int radius, int xCenter, int yCenter, int x1, int y1, int x2, int y2) {
public boolean checkOverlap(
int radius, int xCenter, int yCenter, int x1, int y1, int x2, int y2) {
int a = f(x1, x2, xCenter);
int b = f(y1, y2, yCenter);
return a * a + b * b <= radius * radius;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ class Solution:

```java
class Solution {
public boolean checkOverlap(int radius, int xCenter, int yCenter, int x1, int y1, int x2, int y2) {
public boolean checkOverlap(
int radius, int xCenter, int yCenter, int x1, int y1, int x2, int y2) {
int a = f(x1, x2, xCenter);
int b = f(y1, y2, yCenter);
return a * a + b * b <= radius * radius;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class Solution {
public boolean checkOverlap(int radius, int xCenter, int yCenter, int x1, int y1, int x2, int y2) {
public boolean checkOverlap(
int radius, int xCenter, int yCenter, int x1, int y1, int x2, int y2) {
int a = f(x1, x2, xCenter);
int b = f(y1, y2, yCenter);
return a * a + b * b <= radius * radius;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* // You should not implement it, or speculate about its implementation
* class ArrayReader {
* public:
* // Compares the sum of arr[l..r] with the sum of arr[x..y]
* // Compares the sum of arr[l..r] with the sum of arr[x..y]
* // return 1 if sum(arr[l..r]) > sum(arr[x..y])
* // return 0 if sum(arr[l..r]) == sum(arr[x..y])
* // return -1 if sum(arr[l..r]) < sum(arr[x..y])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* public:
* // Return the width of char ch when fontSize is used.
* int getWidth(int fontSize, char ch);
*
*
* // Return Height of any char when fontSize is used.
* int getHeight(int fontSize)
* };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class MyNode : public Node {

/**
* This is the TreeBuilder class.
* You can treat it as the driver code that takes the postinfix input
* You can treat it as the driver code that takes the postinfix input
* and returns the expression tree represnting it as a Node.
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class Solution {
public int minMoves(int[] nums, int limit) {
int n = nums.length;
int[] d = new int[limit * 2 + 2];
for (int i = 0; i<n> > 1; ++i) {
for (int i = 0; i < n >> 1; ++i) {
int a = Math.min(nums[i], nums[n - i - 1]);
int b = Math.max(nums[i], nums[n - i - 1]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class Solution {
public int minMoves(int[] nums, int limit) {
int n = nums.length;
int[] d = new int[limit * 2 + 2];
for (int i = 0; i<n> > 1; ++i) {
for (int i = 0; i < n >> 1; ++i) {
int a = Math.min(nums[i], nums[n - i - 1]);
int b = Math.max(nums[i], nums[n - i - 1]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Solution {
int minMoves(vector<int>& nums, int limit) {
int n = nums.size();
vector<int> d(limit * 2 + 2);
for (int i = 0; i<n> > 1; ++i) {
for (int i = 0; i < n >> 1; ++i) {
int a = min(nums[i], nums[n - i - 1]);
int b = max(nums[i], nums[n - i - 1]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class Solution {
public int minMoves(int[] nums, int limit) {
int n = nums.length;
int[] d = new int[limit * 2 + 2];
for (int i = 0; i<n> > 1; ++i) {
for (int i = 0; i < n >> 1; ++i) {
int a = Math.min(nums[i], nums[n - i - 1]);
int b = Math.max(nums[i], nums[n - i - 1]);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
int countMatches(char*** items, int itemsSize, int* itemsColSize, char* ruleKey, char* ruleValue) {
int k = strcmp(ruleKey, "type") == 0 ? 0 : strcmp(ruleKey, "color") == 0 ? 1 : 2;
int k = strcmp(ruleKey, "type") == 0 ? 0 : strcmp(ruleKey, "color") == 0 ? 1
: 2;
int res = 0;
for (int i = 0; i < itemsSize; i++) {
if (strcmp(items[i][k], ruleValue) == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class Solution {
int n = nums.length;
int[] a = new int[(n + 1) >> 1];
int[] b = new int[n >> 1];
for (int i = 0, j = 0; j<n> > 1; i += 2, ++j) {
for (int i = 0, j = 0; j < n >> 1; i += 2, ++j) {
a[j] = nums[i];
b[j] = nums[i + 1];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class Solution {
int n = nums.length;
int[] a = new int[(n + 1) >> 1];
int[] b = new int[n >> 1];
for (int i = 0, j = 0; j<n> > 1; i += 2, ++j) {
for (int i = 0, j = 0; j < n >> 1; i += 2, ++j) {
a[j] = nums[i];
b[j] = nums[i + 1];
}
Expand Down
Loading