Skip to content

Commit 081dc70

Browse files
authored
Merge branch 'doocs:main' into main
2 parents cf04210 + ca10516 commit 081dc70

File tree

1,064 files changed

+41305
-29994
lines changed

Some content is hidden

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

1,064 files changed

+41305
-29994
lines changed

images/starcharts.svg

Lines changed: 18149 additions & 17830 deletions
Loading

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/README_EN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class WordsFrequency {
7171
cnt.merge(x, 1, Integer::sum);
7272
}
7373
}
74-
74+
7575
public int get(String word) {
7676
return cnt.getOrDefault(word, 0);
7777
}
@@ -94,7 +94,7 @@ public:
9494
++cnt[x];
9595
}
9696
}
97-
97+
9898
int get(string word) {
9999
return cnt[word];
100100
}

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
}

0 commit comments

Comments
 (0)