Skip to content

Commit 85a0a76

Browse files
committed
docs: code format
1 parent e6906e4 commit 85a0a76

File tree

790 files changed

+1654
-3826
lines changed

Some content is hidden

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

790 files changed

+1654
-3826
lines changed

basic/searching/BinarySearch/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,12 @@ int search(int left, int right) {
2525
### 模板 2
2626

2727
```java
28-
boolean check(int x) {}
28+
boolean
29+
check(int x) {
30+
}
2931

30-
int search(int left, int right) {
32+
int
33+
search(int left, int right) {
3134
while (left < right) {
3235
int mid = (left + right + 1) >> 1;
3336
if (check(mid)) {

basic/searching/BinarySearch/README_EN.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@ int search(int left, int right) {
2323
### Template 2
2424

2525
```java
26-
boolean check(int x) {}
26+
boolean
27+
check(int x) {
28+
}
2729

28-
int search(int left, int right) {
30+
int
31+
search(int left, int right) {
2932
while (left < right) {
3033
int mid = (left + right + 1) >> 1;
3134
if (check(mid)) {

basic/sorting/CountingSort/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
### **Java**
1818

1919
```java
20-
public static void sort(int[] nums, int min, int max) {
20+
public static void
21+
sort(int[] nums, int min, int max) {
2122
int[] c = new int[max - min + 1];
2223
for (int v : nums) {
2324
c[v - min]++;

basic/sorting/InsertionSort/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class InsertionSort {
2727
private static void insertionSort(int[] nums) {
2828
for (int i = 1, j, n = nums.length; i < n; ++i) {
2929
int num = nums[i];
30-
for (j = i - 1; j >=0 && nums[j] > num; --j) {
30+
for (j = i - 1; j >= 0 && nums[j] > num; --j) {
3131
nums[j + 1] = nums[j];
3232
}
3333
nums[j + 1] = num;

basic/sorting/QuickSort/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,10 @@ public class Main {
121121
int i = left - 1, j = right + 1;
122122
int x = nums[(left + right) >> 1];
123123
while (i < j) {
124-
while (nums[++i] < x);
125-
while (nums[--j] > x);
124+
while (nums[++i] < x)
125+
;
126+
while (nums[--j] > x)
127+
;
126128
if (i < j) {
127129
int t = nums[i];
128130
nums[i] = nums[j];

basic/sorting/SelectionSort/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public class SelectionSort {
3737
System.out.println(Arrays.toString(nums));
3838
}
3939
}
40-
4140
```
4241

4342
### **JavaScript**

basic/sorting/ShellSort/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class ShellSort {
3636
}
3737

3838
public static void main(String[] args) {
39-
System.out.println(Arrays.toString(shellSort(new int[]{1, 2, 7, 9, 5, 8})));
39+
System.out.println(Arrays.toString(shellSort(new int[] {1, 2, 7, 9, 5, 8})));
4040
}
4141
}
4242
```

lcci/02.05.Sum Lists/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ class Solution {
8080
ListNode dummy = new ListNode(-1);
8181
ListNode cur = dummy;
8282
while (l1 != null || l2 != null || carry != 0) {
83-
int s =
84-
(l1 == null ? 0 : l1.val) + (l2 == null ? 0 : l2.val) + carry;
83+
int s = (l1 == null ? 0 : l1.val) + (l2 == null ? 0 : l2.val) + carry;
8584
carry = s / 10;
8685
cur.next = new ListNode(s % 10);
8786
cur = cur.next;

lcci/02.05.Sum Lists/README_EN.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ class Solution {
7575
ListNode dummy = new ListNode(-1);
7676
ListNode cur = dummy;
7777
while (l1 != null || l2 != null || carry != 0) {
78-
int s =
79-
(l1 == null ? 0 : l1.val) + (l2 == null ? 0 : l2.val) + carry;
78+
int s = (l1 == null ? 0 : l1.val) + (l2 == null ? 0 : l2.val) + carry;
8079
carry = s / 10;
8180
cur.next = new ListNode(s % 10);
8281
cur = cur.next;

lcci/03.03.Stack of Plates/README.md

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,45 @@
11
# [面试题 03.03. 堆盘子](https://leetcode.cn/problems/stack-of-plates-lcci)
2-
32
[English Version](/lcci/03.03.Stack%20of%20Plates/README_EN.md)
4-
53
## 题目描述
6-
74
<!-- 这里写题目描述 -->
85
<p>堆盘子。设想有一堆盘子,堆太高可能会倒下来。因此,在现实生活中,盘子堆到一定高度时,我们就会另外堆一堆盘子。请实现数据结构<code>SetOfStacks</code>,模拟这种行为。<code>SetOfStacks</code>应该由多个栈组成,并且在前一个栈填满时新建一个栈。此外,<code>SetOfStacks.push()</code>和<code>SetOfStacks.pop()</code>应该与普通栈的操作方法相同(也就是说,pop()返回的值,应该跟只有一个栈时的情况一样)。 进阶:实现一个<code>popAt(int index)</code>方法,根据指定的子栈,执行pop操作。</p>
9-
106
<p>当某个栈为空时,应当删除该栈。当栈中没有元素或不存在该栈时,<code>pop</code>,<code>popAt</code>&nbsp;应返回 -1.</p>
11-
127
<p><strong>示例1:</strong></p>
13-
148
<pre><strong> 输入</strong>:
159
[&quot;StackOfPlates&quot;, &quot;push&quot;, &quot;push&quot;, &quot;popAt&quot;, &quot;pop&quot;, &quot;pop&quot;]
1610
[[1], [1], [2], [1], [], []]
1711
<strong> 输出</strong>:
1812
[null, null, null, 2, 1, -1]
1913
</pre>
20-
2114
<p><strong>示例2:</strong></p>
22-
2315
<pre><strong> 输入</strong>:
2416
[&quot;StackOfPlates&quot;, &quot;push&quot;, &quot;push&quot;, &quot;push&quot;, &quot;popAt&quot;, &quot;popAt&quot;, &quot;popAt&quot;]
2517
[[2], [1], [2], [3], [0], [0], [0]]
2618
<strong> 输出</strong>:
2719
[null, null, null, null, 2, 1, 3]
2820
</pre>
29-
3021
## 解法
31-
3222
<!-- 这里可写通用的实现逻辑 -->
33-
3423
<!-- tabs:start -->
35-
3624
### **Python3**
37-
3825
<!-- 这里可写当前语言的特殊实现逻辑 -->
39-
4026
```python
4127

42-
4328
```
44-
4529
### **Java**
46-
4730
<!-- 这里可写当前语言的特殊实现逻辑 -->
48-
4931
```java
5032

51-
5233
```
53-
5434
### **TypeScript**
55-
5635
```ts
5736
class StackOfPlates {
5837
private cap: number;
5938
private stacks: number[][];
60-
6139
constructor(cap: number) {
6240
this.cap = cap;
6341
this.stacks = [];
6442
}
65-
6643
push(val: number): void {
6744
if (this.cap === 0) {
6845
return;
@@ -75,7 +52,6 @@ class StackOfPlates {
7552
stack.push(val);
7653
}
7754
}
78-
7955
pop(): number {
8056
const n = this.stacks.length;
8157
if (n === 0) {
@@ -88,7 +64,6 @@ class StackOfPlates {
8864
}
8965
return res;
9066
}
91-
9267
popAt(index: number): number {
9368
if (index >= this.stacks.length) {
9469
return -1;
@@ -101,7 +76,6 @@ class StackOfPlates {
10176
return res;
10277
}
10378
}
104-
10579
/**
10680
* Your StackOfPlates object will be instantiated and called as such:
10781
* var obj = new StackOfPlates(cap)
@@ -110,12 +84,8 @@ class StackOfPlates {
11084
* var param_3 = obj.popAt(index)
11185
*/
11286
```
113-
11487
### **...**
115-
11688
```
11789
118-
11990
```
120-
12191
<!-- tabs:end -->

0 commit comments

Comments
 (0)