Skip to content

Commit dba68ba

Browse files
JavaScalaDeveloperJavaScalaDeveloper
authored andcommitted
导出前1500道
1 parent fdea593 commit dba68ba

File tree

814 files changed

+134401
-1415
lines changed

Some content is hidden

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

814 files changed

+134401
-1415
lines changed

change/scripts/MergeMdFilesByLevel.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import java.util.stream.Collectors;
99

1010
public class MergeMdFilesByLevel {
11+
// 前1500道
12+
private static final int MAX_NUM = 1500;
1113
private static final String OUTPUT_PATH = "D:\\WorkSpaces\\leetcode-all\\change\\scripts\\out\\"; // 修改为输出文件路径
1214
//题号->难度
1315
private static final Map<String, String> num2LevelMap = ParseMenu.getLineData().stream()
@@ -23,9 +25,9 @@ public static void main(String[] args) throws IOException {
2325
}
2426
Map<String, FileOutputStream> fileOutputStreamsMap = new HashMap<>();
2527
// 中等, 困难, 简单
26-
fileOutputStreamsMap.put("简单", new FileOutputStream(OUTPUT_PATH + "easy-v2023.md"));
27-
fileOutputStreamsMap.put("中等", new FileOutputStream(OUTPUT_PATH + "medium-v2023.md"));
28-
fileOutputStreamsMap.put("困难", new FileOutputStream(OUTPUT_PATH + "hard-v2023.md"));
28+
fileOutputStreamsMap.put("简单", new FileOutputStream(OUTPUT_PATH + "easy-0~" + MAX_NUM + "-v2023.md"));
29+
fileOutputStreamsMap.put("中等", new FileOutputStream(OUTPUT_PATH + "medium-0~" + MAX_NUM + "-v2023.md"));
30+
fileOutputStreamsMap.put("困难", new FileOutputStream(OUTPUT_PATH + "hard-0~" + MAX_NUM + "-v2023.md"));
2931

3032
mergeMdFiles(dir, fileOutputStreamsMap);
3133
fileOutputStreamsMap.forEach((s, fileOutputStream) -> {
@@ -47,15 +49,18 @@ private static void mergeMdFiles(File dir, Map<String, FileOutputStream> fileOut
4749
} else if (basicFileAttributes.isRegularFile() && file.getName().endsWith(".md")) {
4850
FileInputStream fis = new FileInputStream(file);
4951
String path = file.getPath();
50-
if (path.length() > 50) {
52+
if (path.length() > 60) {
5153
// 题号
5254
String num = path.substring(46, 50);
55+
int intNum = Integer.parseInt(num);
56+
if (intNum <= MAX_NUM) {
5357
// 难度
54-
String level = num2LevelMap.get(num);
55-
FileOutputStream os = fileOutputStreamsMap.get(level);
56-
if (os != null) {
57-
System.out.println(num + "-->" + level);
58-
copy(fis, os);
58+
String level = num2LevelMap.get(num);
59+
FileOutputStream os = fileOutputStreamsMap.get(level);
60+
if (os != null) {
61+
System.out.println(num + "-->" + level);
62+
copy(fis, os);
63+
}
5964
}
6065
}
6166
fis.close();

0 commit comments

Comments
 (0)