Skip to content

Commit 5498207

Browse files
committed
修复某些情况下, allcase 没解析成功,如 1040 题
1 parent c1f1b0a commit 5498207

File tree

3 files changed

+40
-30
lines changed

3 files changed

+40
-30
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## version 2.19.3
2+
3+
- 修复某些情况下, allcase 没解析成功,如 1040 题
4+
15
## version 2.19.2
26

37
- 修复某些情况下调用 allcase 报错,如 1017 题

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vscode-leetcode-problem-rating",
33
"displayName": "LeetCode",
44
"description": "%main.description%",
5-
"version": "2.19.2",
5+
"version": "2.19.3",
66
"author": "ccagml",
77
"publisher": "ccagml",
88
"license": "MIT",

src/rpc/utils/storageUtils.ts

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -342,28 +342,26 @@ class StorageUtils {
342342
let temp_collect = "";
343343
for (let all_input = 0; all_input < input.length; all_input++) {
344344
const element = input[all_input];
345-
let check_index = element.indexOf("输入:");
346-
347-
if (check_index == -1) {
348-
check_index = element.indexOf("输入:");
349-
}
345+
let check_input_1 = element.indexOf("输入:");
346+
let check_input_2 = element.indexOf("输入:");
347+
let check_input_3 = element.indexOf("Input:");
348+
if (check_input_1 != -1 || check_input_2 != -1 || check_input_3 != -1) {
349+
if (check_input_1 != -1) {
350+
temp_collect += element.substring(check_input_1 + 3);
351+
} else if (check_input_2 != -1) {
352+
temp_collect += element.substring(check_input_2 + 3);
353+
} else if (check_input_3 != -1) {
354+
temp_collect += element.substring(check_input_3 + 6);
355+
}
350356

351-
if (check_index == -1) {
352-
check_index = element.indexOf("Input:");
353-
}
354-
if (check_index != -1) {
355-
temp_collect += element.substring(check_index + 1);
356357
start_flag = true;
357358
continue;
358359
}
359-
check_index = element.indexOf("输出:");
360-
if (check_index == -1) {
361-
check_index = element.indexOf("输出:");
362-
}
363-
if (check_index == -1) {
364-
check_index = element.indexOf("Output:");
365-
}
366-
if (check_index != -1) {
360+
361+
let check_index_1 = element.indexOf("输出:");
362+
let check_index_2 = element.indexOf("输出:");
363+
let check_index_3 = element.indexOf("Output:");
364+
if (check_index_1 != -1 || check_index_2 != -1 || check_index_3 != -1) {
367365
start_flag = false;
368366
}
369367
if (start_flag) {
@@ -374,21 +372,29 @@ class StorageUtils {
374372
let temp_case: Array<any> = [];
375373
let wait_cur = "";
376374
let no_need_flag = false;
377-
for (let index = new_ele.length - 1; index >= 0; index--) {
378-
if (no_need_flag) {
379-
if (new_ele[index] == ",") {
380-
no_need_flag = false;
381-
}
382-
} else {
383-
if (new_ele[index] == "=") {
384-
temp_case.push(wait_cur.trim());
385-
no_need_flag = true;
386-
wait_cur = "";
375+
376+
// 1040题的输入不标准 没有 x = aaa
377+
if (temp_collect.indexOf("=") == -1) {
378+
temp_case.push(temp_collect.trim());
379+
} else {
380+
// 解析 x = aaa, y = bbb 之类的输入参数
381+
for (let index = new_ele.length - 1; index >= 0; index--) {
382+
if (no_need_flag) {
383+
if (new_ele[index] == ",") {
384+
no_need_flag = false;
385+
}
387386
} else {
388-
wait_cur = new_ele[index] + wait_cur;
387+
if (new_ele[index] == "=") {
388+
temp_case.push(wait_cur.trim());
389+
no_need_flag = true;
390+
wait_cur = "";
391+
} else {
392+
wait_cur = new_ele[index] + wait_cur;
393+
}
389394
}
390395
}
391396
}
397+
392398
let new_temp_case: Array<any> = [];
393399
for (let tci = temp_case.length - 1; tci >= 0; tci--) {
394400
new_temp_case.push(temp_case[tci]);

0 commit comments

Comments
 (0)