Skip to content

Commit a95f30c

Browse files
aQuaaQua
aQua
authored and
aQua
committed
helper 修复了一处获取函数的不兼容情况。
1 parent fa8de20 commit a95f30c

File tree

4 files changed

+71
-1
lines changed

4 files changed

+71
-1
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# [56. Merge Intervals](https://leetcode.com/problems/merge-intervals/)
2+
3+
## 题目
4+
Given a collection of intervals, merge all overlapping intervals.
5+
6+
7+
For example,
8+
Given [1,3],[2,6],[8,10],[15,18],
9+
return [1,6],[8,10],[15,18].
10+
## 解题思路
11+
12+
见程序注释
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package Problem0056
2+
3+
func merge(intervals []Interval) []Interval {
4+
5+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package Problem0056
2+
3+
import (
4+
"testing"
5+
"fmt"
6+
7+
"github.com/stretchr/testify/assert"
8+
)
9+
10+
type question struct {
11+
para
12+
ans
13+
}
14+
15+
// para 是参数
16+
type para struct {
17+
intervals []Interval
18+
}
19+
20+
// ans 是答案
21+
type ans struct {
22+
one []Interval
23+
}
24+
25+
func Test_Problem0056(t *testing.T) {
26+
ast := assert.New(t)
27+
28+
qs := []question{
29+
30+
question{
31+
para{
32+
,
33+
},
34+
ans{
35+
,
36+
},
37+
},
38+
39+
// 如需多个测试,可以复制上方元素。
40+
}
41+
42+
for _, q := range qs {
43+
a, p := q.ans, q.para
44+
fmt.Printf("~~%v~~\n", p)
45+
46+
ast.Equal(a.one, merge(p. ), "输入:%v", p)
47+
}
48+
}

helper.v3/problem.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,15 @@ func getFunction(URL string) (fc, fcHead, p, a string) {
9797
j := i + strings.Index(str[i:], "enableTestMode:")
9898
str = str[i:j]
9999

100-
i = strings.Index(str, "'func")
100+
i = strings.Index(str, "'Go', 'defaultCode': ") + 21
101101
j = i + strings.Index(str[i:], "},")
102102
str = str[i:j]
103103

104+
i = strings.Index(str, "func")
105+
str = "'" + str[i:]
106+
107+
// fmt.Println("getFunction: ", str)
108+
104109
i = strings.Index(str, "'")
105110
j = 5 + strings.Index(str[5:], "'")
106111
fc = str[i+1 : j]

0 commit comments

Comments
 (0)