Skip to content

Commit 1a44316

Browse files
JavaScalaDeveloperJavaScalaDeveloper
authored andcommitted
合并所有的solution
1 parent 356fd4e commit 1a44316

File tree

3,099 files changed

+279276
-89797
lines changed

Some content is hidden

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

3,099 files changed

+279276
-89797
lines changed

basic/sorting/BubbleSort/README.md

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
## 代码示例
88

9-
<!-- tabs:start -->
10-
119
### **Java**
1210

1311
```java
@@ -42,32 +40,6 @@ public class BubbleSort {
4240
}
4341
```
4442

45-
46-
47-
48-
49-
50-
51-
52-
53-
54-
55-
56-
57-
58-
59-
60-
61-
62-
63-
64-
65-
### **Python3**
66-
67-
68-
69-
70-
7143
## 算法分析
7244

7345
空间复杂度 $O(1)$、时间复杂度 $O(n^2)$。

basic/sorting/CountingSort/README.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212

1313
## 代码示例
1414

15-
<!-- tabs:start -->
16-
1715
### **Java**
1816

1917
```java
@@ -36,12 +34,6 @@ public static void sort(int[] nums, int min, int max) {
3634
}
3735
```
3836

39-
40-
41-
42-
43-
44-
4537
## 算法分析
4638

4739
- 时间复杂度 $O(n+k)$, 其中 $n$ 为排序数组长度,而 $k$ 为排序数组中数值的取值范围,当 $k\lt n$ 时,时间复杂度为 $O(n)$。

basic/sorting/HeapSort/README.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,6 @@ for (int i = n / 2; i > 0; --i) {
6969

7070
## 代码实现
7171

72-
<!-- tabs:start -->
73-
74-
### **Python3**
75-
76-
77-
7872
### **Java**
7973

8074
```java
@@ -129,13 +123,3 @@ public class Main {
129123
}
130124
}
131125
```
132-
133-
134-
135-
136-
137-
138-
139-
140-
141-

basic/sorting/InsertionSort/README.md

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515

1616
## 代码示例
1717

18-
<!-- tabs:start -->
19-
2018
### **Java**
2119

2220
```java
@@ -42,32 +40,6 @@ public class InsertionSort {
4240
}
4341
```
4442

45-
46-
47-
48-
49-
50-
51-
52-
53-
54-
55-
56-
57-
58-
59-
60-
61-
62-
63-
64-
65-
### **Python3**
66-
67-
68-
69-
70-
7143
## 算法分析
7244

7345
空间复杂度 $O(1)$,时间复杂度 $O(n^2)$。

basic/sorting/MergeSort/README.md

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,6 @@ void mergeSort(int[] nums, int left, int right) {
7171

7272
## 代码实现
7373

74-
<!-- tabs:start -->
75-
76-
### **Python3**
77-
78-
79-
8074
### **Java**
8175

8276
```java
@@ -125,21 +119,3 @@ public class Main {
125119
}
126120
}
127121
```
128-
129-
130-
131-
132-
133-
134-
135-
136-
137-
138-
139-
140-
141-
142-
143-
144-
145-

basic/sorting/QuickSort/README.md

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,6 @@ void quickSort(int[] nums, int left, int right) {
6262

6363
## 代码实现
6464

65-
<!-- tabs:start -->
66-
67-
### **Python3**
68-
69-
70-
7165
### **Java**
7266

7367
```java
@@ -109,21 +103,3 @@ public class Main {
109103
}
110104
}
111105
```
112-
113-
114-
115-
116-
117-
118-
119-
120-
121-
122-
123-
124-
125-
126-
127-
128-
129-

basic/sorting/SelectionSort/README.md

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
## 代码示例
66

7-
<!-- tabs:start -->
8-
97
### **Java**
108

119
```java
@@ -39,32 +37,6 @@ public class SelectionSort {
3937
}
4038
```
4139

42-
43-
44-
45-
46-
47-
48-
49-
50-
51-
52-
53-
54-
55-
56-
57-
58-
59-
60-
61-
62-
### **Python3**
63-
64-
65-
66-
67-
6840
## 算法分析
6941

7042
空间复杂度 $O(1)$,时间复杂度 $O(n^2)$。

basic/sorting/ShellSort/README.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
## 代码示例
1111

12-
<!-- tabs:start -->
13-
1412
### **Java**
1513

1614
```java
@@ -41,20 +39,6 @@ public class ShellSort {
4139
}
4240
```
4341

44-
45-
46-
47-
48-
49-
50-
51-
52-
53-
54-
55-
56-
57-
5842
## 算法分析
5943

6044
时间复杂度:

change/scripts/Main.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package change.scripts;
2+
3+
import java.io.IOException;
4+
5+
import java.nio.file.Files;
6+
import java.nio.file.Paths;
7+
import java.util.regex.Matcher;
8+
import java.util.regex.Pattern;
9+
10+
public class Main {
11+
public static void main(String[] args) {
12+
String filePath = "D:\\WorkSpaces\\leetcode-all\\solution\\0000-0099\\0001.Two Sum\\README.md";
13+
String str = null;
14+
try {
15+
str = new String(Files.readAllBytes(Paths.get(filePath)));
16+
} catch (IOException e) {
17+
e.printStackTrace();
18+
}
19+
20+
21+
// String str = "caergblkmghfaersnecsblixetwey";
22+
Pattern pattern = Pattern.compile("");
23+
Matcher matcher = pattern.matcher(str);
24+
if (matcher.find()) {
25+
int startIndex = matcher.start();
26+
int endIndex = matcher.end();
27+
String result = str.substring(0, startIndex) + str.substring(endIndex);
28+
System.out.println(result);
29+
} else {
30+
System.out.println(str);
31+
}
32+
33+
34+
}
35+
}

change/scripts/MergeMdFiles.java

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package change.scripts;
2+
3+
import java.io.*;
4+
5+
public class MergeMdFiles {
6+
7+
public static void main(String[] args) throws IOException {
8+
String directory = "D:\\WorkSpaces\\leetcode-all\\solution"; // 修改为目录路径
9+
String outputFile = "D:\\WorkSpaces\\leetcode-all\\change\\scripts\\out\\output-file.md"; // 修改为输出文件路径
10+
11+
File dir = new File(directory);
12+
if (!dir.exists() || !dir.isDirectory()) {
13+
System.out.println("目录不存在或者不是一个目录");
14+
return;
15+
}
16+
17+
FileOutputStream fos = new FileOutputStream(outputFile);
18+
mergeMdFiles(dir, fos);
19+
fos.close();
20+
}
21+
22+
private static void mergeMdFiles(File dir, OutputStream os) throws IOException {
23+
File[] files = dir.listFiles();
24+
for (File file : files) {
25+
if (file.isDirectory()) {
26+
mergeMdFiles(file, os);
27+
} else if (file.isFile() && file.getName().endsWith(".md")) {
28+
FileInputStream fis = new FileInputStream(file);
29+
copy(fis, os);
30+
fis.close();
31+
}
32+
}
33+
}
34+
35+
private static void copy(InputStream is, OutputStream os) throws IOException {
36+
byte[] buffer = new byte[4096];
37+
int len;
38+
while ((len = is.read(buffer)) != -1) {
39+
os.write(buffer, 0, len);
40+
}
41+
}
42+
43+
}

0 commit comments

Comments
 (0)