8
8
import java .util .stream .Collectors ;
9
9
10
10
public class MergeMdFilesByLevel {
11
+ // 前1500道
12
+ private static final int MAX_NUM = 1500 ;
11
13
private static final String OUTPUT_PATH = "D:\\ WorkSpaces\\ leetcode-all\\ change\\ scripts\\ out\\ " ; // 修改为输出文件路径
12
14
//题号->难度
13
15
private static final Map <String , String > num2LevelMap = ParseMenu .getLineData ().stream ()
@@ -23,9 +25,9 @@ public static void main(String[] args) throws IOException {
23
25
}
24
26
Map <String , FileOutputStream > fileOutputStreamsMap = new HashMap <>();
25
27
// 中等, 困难, 简单
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" ));
29
31
30
32
mergeMdFiles (dir , fileOutputStreamsMap );
31
33
fileOutputStreamsMap .forEach ((s , fileOutputStream ) -> {
@@ -47,15 +49,18 @@ private static void mergeMdFiles(File dir, Map<String, FileOutputStream> fileOut
47
49
} else if (basicFileAttributes .isRegularFile () && file .getName ().endsWith (".md" )) {
48
50
FileInputStream fis = new FileInputStream (file );
49
51
String path = file .getPath ();
50
- if (path .length () > 50 ) {
52
+ if (path .length () > 60 ) {
51
53
// 题号
52
54
String num = path .substring (46 , 50 );
55
+ int intNum = Integer .parseInt (num );
56
+ if (intNum <= MAX_NUM ) {
53
57
// 难度
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
+ }
59
64
}
60
65
}
61
66
fis .close ();
0 commit comments