Skip to content

Commit d7150f6

Browse files
committed
style: format code
1 parent 7808672 commit d7150f6

File tree

476 files changed

+880
-809
lines changed

Some content is hidden

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

476 files changed

+880
-809
lines changed

lcci/01.02.Check Permutation/Solution.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ class Solution {
33
bool CheckPermutation(string s1, string s2) {
44
if (s1.size() != s2.size()) return false;
55
int cnt[26] = {0};
6-
for (char & c : s1) ++cnt[c - 'a'];
7-
for (char & c : s2) if (--cnt[c - 'a'] < 0) return false;
6+
for (char& c : s1) ++cnt[c - 'a'];
7+
for (char& c : s2)
8+
if (--cnt[c - 'a'] < 0) return false;
89
return true;
910
}
1011
};

lcci/01.04.Palindrome Permutation/Solution.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class Solution {
22
public boolean canPermutePalindrome(String s) {
3-
Map<Character, Integer> cnt = new HashMap<>();
3+
Map<Character, Integer> cnt = new HashMap<>();
44
for (int i = 0; i < s.length(); ++i) {
55
cnt.merge(s.charAt(i), 1, Integer::sum);
66
}

lcci/01.08.Zero Matrix/Solution.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
void setZeroes(int **matrix, int matrixSize, int *matrixColSize) {
1+
void setZeroes(int** matrix, int matrixSize, int* matrixColSize) {
22
int m = matrixSize;
33
int n = matrixColSize[0];
44
int l0 = 0;

lcci/03.02.Min Stack/Solution.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@ class MinStack {
66
public MinStack() {
77
stk2.push(Integer.MAX_VALUE);
88
}
9-
9+
1010
public void push(int x) {
1111
stk1.push(x);
1212
stk2.push(Math.min(x, stk2.peek()));
1313
}
14-
14+
1515
public void pop() {
1616
stk1.pop();
1717
stk2.pop();
1818
}
19-
19+
2020
public int top() {
2121
return stk1.peek();
2222
}
23-
23+
2424
public int getMin() {
2525
return stk2.peek();
2626
}

lcci/03.03.Stack of Plates/Solution.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class StackOfPlates {
55
public StackOfPlates(int cap) {
66
this.cap = cap;
77
}
8-
8+
99
public void push(int val) {
1010
if (cap == 0) {
1111
return;
@@ -15,11 +15,11 @@ public void push(int val) {
1515
}
1616
stk.get(stk.size() - 1).push(val);
1717
}
18-
18+
1919
public int pop() {
2020
return popAt(stk.size() - 1);
2121
}
22-
22+
2323
public int popAt(int index) {
2424
int ans = -1;
2525
if (index >= 0 && index < stk.size()) {

lcci/08.10.Color Fill/Solution.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ public int[][] floodFill(int[][] image, int sr, int sc, int newColor) {
1313
}
1414

1515
private void dfs(int i, int j) {
16-
if (i < 0 || i >= image.length || j < 0 || j >= image[0].length || image[i][j] != oc || image[i][j] == nc) {
16+
if (i < 0 || i >= image.length || j < 0 || j >= image[0].length || image[i][j] != oc
17+
|| image[i][j] == nc) {
1718
return;
1819
}
1920
image[i][j] = nc;

lcci/16.02.Words Frequency/Solution.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class WordsFrequency {
55
++cnt[x];
66
}
77
}
8-
8+
99
int get(string word) {
1010
return cnt[word];
1111
}

lcci/16.02.Words Frequency/Solution.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public WordsFrequency(String[] book) {
66
cnt.merge(x, 1, Integer::sum);
77
}
88
}
9-
9+
1010
public int get(String word) {
1111
return cnt.getOrDefault(word, 0);
1212
}

lcci/16.14.Best Line/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,11 @@ class Solution {
138138
int g = gcd(dx, dy);
139139
String key = (dx / g) + "." + (dy / g);
140140
cnt.computeIfAbsent(key, k -> new ArrayList<>()).add(new int[] {i, j});
141-
if (mx < cnt.get(key).size() || (mx == cnt.get(key).size() && (ans[0] > cnt.get(key).get(0)[0] || (ans[0] == cnt.get(key).get(0)[0] && ans[1] > cnt.get(key).get(0)[1])))) {
141+
if (mx < cnt.get(key).size()
142+
|| (mx == cnt.get(key).size()
143+
&& (ans[0] > cnt.get(key).get(0)[0]
144+
|| (ans[0] == cnt.get(key).get(0)[0]
145+
&& ans[1] > cnt.get(key).get(0)[1])))) {
142146
mx = cnt.get(key).size();
143147
ans = cnt.get(key).get(0);
144148
}

lcci/16.14.Best Line/README_EN.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,11 @@ class Solution {
120120
int g = gcd(dx, dy);
121121
String key = (dx / g) + "." + (dy / g);
122122
cnt.computeIfAbsent(key, k -> new ArrayList<>()).add(new int[] {i, j});
123-
if (mx < cnt.get(key).size() || (mx == cnt.get(key).size() && (ans[0] > cnt.get(key).get(0)[0] || (ans[0] == cnt.get(key).get(0)[0] && ans[1] > cnt.get(key).get(0)[1])))) {
123+
if (mx < cnt.get(key).size()
124+
|| (mx == cnt.get(key).size()
125+
&& (ans[0] > cnt.get(key).get(0)[0]
126+
|| (ans[0] == cnt.get(key).get(0)[0]
127+
&& ans[1] > cnt.get(key).get(0)[1])))) {
124128
mx = cnt.get(key).size();
125129
ans = cnt.get(key).get(0);
126130
}

0 commit comments

Comments
 (0)