mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-05 00:25:22 +08:00
optimization code level from A to A+
This commit is contained in:
@ -26,32 +26,30 @@ type ans1 struct {
|
||||
func Test_Problem1(t *testing.T) {
|
||||
|
||||
qs := []question1{
|
||||
|
||||
question1{
|
||||
{
|
||||
para1{[]int{3, 2, 4}, 6},
|
||||
ans1{[]int{1, 2}},
|
||||
},
|
||||
|
||||
question1{
|
||||
{
|
||||
para1{[]int{3, 2, 4}, 5},
|
||||
ans1{[]int{0, 1}},
|
||||
},
|
||||
|
||||
question1{
|
||||
{
|
||||
para1{[]int{0, 8, 7, 3, 3, 4, 2}, 11},
|
||||
ans1{[]int{1, 3}},
|
||||
},
|
||||
|
||||
question1{
|
||||
{
|
||||
para1{[]int{0, 1}, 1},
|
||||
ans1{[]int{0, 1}},
|
||||
},
|
||||
|
||||
question1{
|
||||
{
|
||||
para1{[]int{0, 3}, 5},
|
||||
ans1{[]int{}},
|
||||
},
|
||||
|
||||
// 如需多个测试,可以复制上方元素。
|
||||
}
|
||||
|
||||
|
@ -29,42 +29,42 @@ func Test_Problem2(t *testing.T) {
|
||||
|
||||
qs := []question2{
|
||||
|
||||
question2{
|
||||
{
|
||||
para2{[]int{}, []int{}},
|
||||
ans2{[]int{}},
|
||||
},
|
||||
|
||||
question2{
|
||||
{
|
||||
para2{[]int{1}, []int{1}},
|
||||
ans2{[]int{2}},
|
||||
},
|
||||
|
||||
question2{
|
||||
{
|
||||
para2{[]int{1, 2, 3, 4}, []int{1, 2, 3, 4}},
|
||||
ans2{[]int{2, 4, 6, 8}},
|
||||
},
|
||||
|
||||
question2{
|
||||
{
|
||||
para2{[]int{1, 2, 3, 4, 5}, []int{1, 2, 3, 4, 5}},
|
||||
ans2{[]int{2, 4, 6, 8, 0, 1}},
|
||||
},
|
||||
|
||||
question2{
|
||||
{
|
||||
para2{[]int{1}, []int{9, 9, 9, 9, 9}},
|
||||
ans2{[]int{0, 0, 0, 0, 0, 1}},
|
||||
},
|
||||
|
||||
question2{
|
||||
{
|
||||
para2{[]int{9, 9, 9, 9, 9}, []int{1}},
|
||||
ans2{[]int{0, 0, 0, 0, 0, 1}},
|
||||
},
|
||||
|
||||
question2{
|
||||
{
|
||||
para2{[]int{2, 4, 3}, []int{5, 6, 4}},
|
||||
ans2{[]int{7, 0, 8}},
|
||||
},
|
||||
|
||||
question2{
|
||||
{
|
||||
para2{[]int{1, 8, 3}, []int{7, 1}},
|
||||
ans2{[]int{8, 9, 3}},
|
||||
},
|
||||
|
@ -26,22 +26,22 @@ func Test_Problem3(t *testing.T) {
|
||||
|
||||
qs := []question3{
|
||||
|
||||
question3{
|
||||
{
|
||||
para3{"abcabcbb"},
|
||||
ans3{3},
|
||||
},
|
||||
|
||||
question3{
|
||||
{
|
||||
para3{"bbbbb"},
|
||||
ans3{1},
|
||||
},
|
||||
|
||||
question3{
|
||||
{
|
||||
para3{"pwwkew"},
|
||||
ans3{3},
|
||||
},
|
||||
|
||||
question3{
|
||||
{
|
||||
para3{""},
|
||||
ans3{0},
|
||||
},
|
||||
|
@ -27,12 +27,12 @@ func Test_Problem4(t *testing.T) {
|
||||
|
||||
qs := []question4{
|
||||
|
||||
question4{
|
||||
{
|
||||
para4{[]int{1, 3}, []int{2}},
|
||||
ans4{2.0},
|
||||
},
|
||||
|
||||
question4{
|
||||
{
|
||||
para4{[]int{1, 2}, []int{3, 4}},
|
||||
ans4{2.5},
|
||||
},
|
||||
|
@ -26,22 +26,22 @@ func Test_Problem7(t *testing.T) {
|
||||
|
||||
qs := []question7{
|
||||
|
||||
question7{
|
||||
{
|
||||
para7{321},
|
||||
ans7{123},
|
||||
},
|
||||
|
||||
question7{
|
||||
{
|
||||
para7{-123},
|
||||
ans7{-321},
|
||||
},
|
||||
|
||||
question7{
|
||||
{
|
||||
para7{120},
|
||||
ans7{21},
|
||||
},
|
||||
|
||||
question7{
|
||||
{
|
||||
para7{1534236469},
|
||||
ans7{0},
|
||||
},
|
||||
|
@ -26,37 +26,37 @@ func Test_Problem9(t *testing.T) {
|
||||
|
||||
qs := []question9{
|
||||
|
||||
question9{
|
||||
{
|
||||
para9{121},
|
||||
ans9{true},
|
||||
},
|
||||
|
||||
question9{
|
||||
{
|
||||
para9{-121},
|
||||
ans9{false},
|
||||
},
|
||||
|
||||
question9{
|
||||
{
|
||||
para9{10},
|
||||
ans9{false},
|
||||
},
|
||||
|
||||
question9{
|
||||
{
|
||||
para9{321},
|
||||
ans9{false},
|
||||
},
|
||||
|
||||
question9{
|
||||
{
|
||||
para9{-123},
|
||||
ans9{false},
|
||||
},
|
||||
|
||||
question9{
|
||||
{
|
||||
para9{120},
|
||||
ans9{false},
|
||||
},
|
||||
|
||||
question9{
|
||||
{
|
||||
para9{1534236469},
|
||||
ans9{false},
|
||||
},
|
||||
|
@ -26,12 +26,12 @@ func Test_Problem11(t *testing.T) {
|
||||
|
||||
qs := []question11{
|
||||
|
||||
question11{
|
||||
{
|
||||
para11{[]int{1, 8, 6, 2, 5, 4, 8, 3, 7}},
|
||||
ans11{49},
|
||||
},
|
||||
|
||||
question11{
|
||||
{
|
||||
para11{[]int{1, 1}},
|
||||
ans11{1},
|
||||
},
|
||||
|
@ -26,32 +26,32 @@ func Test_Problem13(t *testing.T) {
|
||||
|
||||
qs := []question13{
|
||||
|
||||
question13{
|
||||
{
|
||||
para13{"III"},
|
||||
ans13{3},
|
||||
},
|
||||
|
||||
question13{
|
||||
{
|
||||
para13{"IV"},
|
||||
ans13{4},
|
||||
},
|
||||
|
||||
question13{
|
||||
{
|
||||
para13{"IX"},
|
||||
ans13{9},
|
||||
},
|
||||
|
||||
question13{
|
||||
{
|
||||
para13{"LVIII"},
|
||||
ans13{58},
|
||||
},
|
||||
|
||||
question13{
|
||||
{
|
||||
para13{"MCMXCIV"},
|
||||
ans13{1994},
|
||||
},
|
||||
|
||||
question13{
|
||||
{
|
||||
para13{"MCMXICIVI"},
|
||||
ans13{2014},
|
||||
},
|
||||
|
@ -26,26 +26,26 @@ func Test_Problem15(t *testing.T) {
|
||||
|
||||
qs := []question15{
|
||||
|
||||
question15{
|
||||
{
|
||||
para15{[]int{0, 0, 0}},
|
||||
ans15{[][]int{[]int{0, 0, 0}}},
|
||||
ans15{[][]int{{0, 0, 0}}},
|
||||
},
|
||||
|
||||
question15{
|
||||
{
|
||||
para15{[]int{-1, 0, 1, 2, -1, -4}},
|
||||
ans15{[][]int{[]int{-1, 0, 1}, []int{-1, -1, 2}}},
|
||||
ans15{[][]int{{-1, 0, 1}, {-1, -1, 2}}},
|
||||
},
|
||||
|
||||
question15{
|
||||
{
|
||||
para15{[]int{-4, -2, -2, -2, 0, 1, 2, 2, 2, 3, 3, 4, 4, 6, 6}},
|
||||
ans15{[][]int{[]int{-4, -2, 6}, []int{-4, 0, 4}, []int{-4, 1, 3}, []int{-4, 2, 2}, []int{-2, -2, 4}, []int{-2, 0, 2}}},
|
||||
ans15{[][]int{{-4, -2, 6}, {-4, 0, 4}, {-4, 1, 3}, {-4, 2, 2}, {-2, -2, 4}, {-2, 0, 2}}},
|
||||
},
|
||||
|
||||
question15{
|
||||
{
|
||||
para15{[]int{5, -7, 3, -3, 5, -10, 4, 8, -3, -8, -3, -3, -1, -8, 6, 4, -4, 7, 2, -5, -2, -7, -3, 7, 2, 4, -6, 5}},
|
||||
ans15{[][]int{[]int{-10, 2, 8}, []int{-10, 3, 7}, []int{-10, 4, 6}, []int{-10, 5, 5}, []int{-8, 2, 6}, []int{-8, 3, 5}, []int{-8, 4, 4}, []int{-7, -1, 8},
|
||||
[]int{-7, 2, 5}, []int{-7, 3, 4}, []int{-6, -2, 8}, []int{-6, -1, 7}, []int{-6, 2, 4}, []int{-5, -3, 8}, []int{-5, -2, 7}, []int{-5, -1, 6}, []int{-5, 2, 3},
|
||||
[]int{-4, -3, 7}, []int{-4, -2, 6}, []int{-4, -1, 5}, []int{-4, 2, 2}, []int{-3, -3, 6}, []int{-3, -2, 5}, []int{-3, -1, 4}, []int{-2, -1, 3}}},
|
||||
ans15{[][]int{{-10, 2, 8}, {-10, 3, 7}, {-10, 4, 6}, {-10, 5, 5}, {-8, 2, 6}, {-8, 3, 5}, {-8, 4, 4}, {-7, -1, 8},
|
||||
{-7, 2, 5}, {-7, 3, 4}, {-6, -2, 8}, {-6, -1, 7}, {-6, 2, 4}, {-5, -3, 8}, {-5, -2, 7}, {-5, -1, 6}, {-5, 2, 3},
|
||||
{-4, -3, 7}, {-4, -2, 6}, {-4, -1, 5}, {-4, 2, 2}, {-3, -3, 6}, {-3, -2, 5}, {-3, -1, 4}, {-2, -1, 3}}},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -27,27 +27,27 @@ func Test_Problem16(t *testing.T) {
|
||||
|
||||
qs := []question16{
|
||||
|
||||
question16{
|
||||
{
|
||||
para16{[]int{-1, 0, 1, 1, 55}, 3},
|
||||
ans16{2},
|
||||
},
|
||||
|
||||
question16{
|
||||
{
|
||||
para16{[]int{0, 0, 0}, 1},
|
||||
ans16{0},
|
||||
},
|
||||
|
||||
question16{
|
||||
{
|
||||
para16{[]int{-1, 2, 1, -4}, 1},
|
||||
ans16{2},
|
||||
},
|
||||
|
||||
question16{
|
||||
{
|
||||
para16{[]int{1, 1, -1}, 0},
|
||||
ans16{1},
|
||||
},
|
||||
|
||||
question16{
|
||||
{
|
||||
para16{[]int{-1, 2, 1, -4}, 1},
|
||||
ans16{2},
|
||||
},
|
||||
|
@ -26,7 +26,7 @@ func Test_Problem17(t *testing.T) {
|
||||
|
||||
qs := []question17{
|
||||
|
||||
question17{
|
||||
{
|
||||
para17{"23"},
|
||||
ans17{[]string{"ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"}},
|
||||
},
|
||||
|
@ -27,29 +27,29 @@ func Test_Problem18(t *testing.T) {
|
||||
|
||||
qs := []question18{
|
||||
|
||||
question18{
|
||||
{
|
||||
para18{[]int{1, 1, 1, 1}, 4},
|
||||
ans18{[][]int{[]int{1, 1, 1, 1}}},
|
||||
ans18{[][]int{{1, 1, 1, 1}}},
|
||||
},
|
||||
|
||||
question18{
|
||||
{
|
||||
para18{[]int{0, 1, 5, 0, 1, 5, 5, -4}, 11},
|
||||
ans18{[][]int{[]int{-4, 5, 5, 5}, []int{0, 1, 5, 5}}},
|
||||
ans18{[][]int{{-4, 5, 5, 5}, {0, 1, 5, 5}}},
|
||||
},
|
||||
|
||||
question18{
|
||||
{
|
||||
para18{[]int{1, 0, -1, 0, -2, 2}, 0},
|
||||
ans18{[][]int{[]int{-1, 0, 0, 1}, []int{-2, -1, 1, 2}, []int{-2, 0, 0, 2}}},
|
||||
ans18{[][]int{{-1, 0, 0, 1}, {-2, -1, 1, 2}, {-2, 0, 0, 2}}},
|
||||
},
|
||||
|
||||
question18{
|
||||
{
|
||||
para18{[]int{1, 0, -1, 0, -2, 2, 0, 0, 0, 0}, 0},
|
||||
ans18{[][]int{[]int{-1, 0, 0, 1}, []int{-2, -1, 1, 2}, []int{-2, 0, 0, 2}, []int{0, 0, 0, 0}}},
|
||||
ans18{[][]int{{-1, 0, 0, 1}, {-2, -1, 1, 2}, {-2, 0, 0, 2}, {0, 0, 0, 0}}},
|
||||
},
|
||||
|
||||
question18{
|
||||
{
|
||||
para18{[]int{1, 0, -1, 0, -2, 2, 0, 0, 0, 0}, 1},
|
||||
ans18{[][]int{[]int{-1, 0, 0, 2}, []int{-2, 0, 1, 2}, []int{0, 0, 0, 1}}},
|
||||
ans18{[][]int{{-1, 0, 0, 2}, {-2, 0, 1, 2}, {0, 0, 0, 1}}},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -29,26 +29,26 @@ func Test_Problem19(t *testing.T) {
|
||||
|
||||
qs := []question19{
|
||||
|
||||
question19{
|
||||
{
|
||||
para19{[]int{1, 2, 3, 4, 5}, 1},
|
||||
ans19{[]int{1, 2, 3, 4}},
|
||||
},
|
||||
|
||||
question19{
|
||||
{
|
||||
para19{[]int{1, 2, 3, 4, 5}, 2},
|
||||
ans19{[]int{1, 2, 3, 5}},
|
||||
},
|
||||
|
||||
question19{
|
||||
{
|
||||
para19{[]int{1, 2, 3, 4, 5}, 3},
|
||||
ans19{[]int{1, 2, 4, 5}},
|
||||
},
|
||||
question19{
|
||||
{
|
||||
para19{[]int{1, 2, 3, 4, 5}, 4},
|
||||
ans19{[]int{1, 3, 4, 5}},
|
||||
},
|
||||
|
||||
question19{
|
||||
{
|
||||
para19{[]int{1, 2, 3, 4, 5}, 5},
|
||||
ans19{[]int{2, 3, 4, 5}},
|
||||
},
|
||||
|
@ -26,35 +26,35 @@ func Test_Problem20(t *testing.T) {
|
||||
|
||||
qs := []question20{
|
||||
|
||||
question20{
|
||||
{
|
||||
para20{"()[]{}"},
|
||||
ans20{true},
|
||||
},
|
||||
question20{
|
||||
{
|
||||
para20{"(]"},
|
||||
ans20{false},
|
||||
},
|
||||
question20{
|
||||
{
|
||||
para20{"({[]})"},
|
||||
ans20{true},
|
||||
},
|
||||
question20{
|
||||
{
|
||||
para20{"(){[({[]})]}"},
|
||||
ans20{true},
|
||||
},
|
||||
question20{
|
||||
{
|
||||
para20{"((([[[{{{"},
|
||||
ans20{false},
|
||||
},
|
||||
question20{
|
||||
{
|
||||
para20{"(())]]"},
|
||||
ans20{false},
|
||||
},
|
||||
question20{
|
||||
{
|
||||
para20{""},
|
||||
ans20{true},
|
||||
},
|
||||
question20{
|
||||
{
|
||||
para20{"["},
|
||||
ans20{false},
|
||||
},
|
||||
|
@ -29,42 +29,42 @@ func Test_Problem21(t *testing.T) {
|
||||
|
||||
qs := []question21{
|
||||
|
||||
question21{
|
||||
{
|
||||
para21{[]int{}, []int{}},
|
||||
ans21{[]int{}},
|
||||
},
|
||||
|
||||
question21{
|
||||
{
|
||||
para21{[]int{1}, []int{1}},
|
||||
ans21{[]int{1, 1}},
|
||||
},
|
||||
|
||||
question21{
|
||||
{
|
||||
para21{[]int{1, 2, 3, 4}, []int{1, 2, 3, 4}},
|
||||
ans21{[]int{1, 1, 2, 2, 3, 3, 4, 4}},
|
||||
},
|
||||
|
||||
question21{
|
||||
{
|
||||
para21{[]int{1, 2, 3, 4, 5}, []int{1, 2, 3, 4, 5}},
|
||||
ans21{[]int{1, 1, 2, 2, 3, 3, 4, 4, 5, 5}},
|
||||
},
|
||||
|
||||
question21{
|
||||
{
|
||||
para21{[]int{1}, []int{9, 9, 9, 9, 9}},
|
||||
ans21{[]int{1, 9, 9, 9, 9, 9}},
|
||||
},
|
||||
|
||||
question21{
|
||||
{
|
||||
para21{[]int{9, 9, 9, 9, 9}, []int{1}},
|
||||
ans21{[]int{1, 9, 9, 9, 9, 9}},
|
||||
},
|
||||
|
||||
question21{
|
||||
{
|
||||
para21{[]int{2, 3, 4}, []int{4, 5, 6}},
|
||||
ans21{[]int{2, 3, 4, 4, 5, 6}},
|
||||
},
|
||||
|
||||
question21{
|
||||
{
|
||||
para21{[]int{1, 3, 8}, []int{1, 7}},
|
||||
ans21{[]int{1, 1, 3, 7, 8}},
|
||||
},
|
||||
|
@ -26,7 +26,7 @@ func Test_Problem22(t *testing.T) {
|
||||
|
||||
qs := []question22{
|
||||
|
||||
question22{
|
||||
{
|
||||
para22{3},
|
||||
ans22{[]string{
|
||||
"((()))",
|
||||
|
@ -28,63 +28,63 @@ func Test_Problem23(t *testing.T) {
|
||||
|
||||
qs := []question23{
|
||||
|
||||
question23{
|
||||
{
|
||||
para23{[][]int{}},
|
||||
ans23{[]int{}},
|
||||
},
|
||||
|
||||
question23{
|
||||
{
|
||||
para23{[][]int{
|
||||
[]int{1},
|
||||
[]int{1},
|
||||
{1},
|
||||
{1},
|
||||
}},
|
||||
ans23{[]int{1, 1}},
|
||||
},
|
||||
|
||||
question23{
|
||||
{
|
||||
para23{[][]int{
|
||||
[]int{1, 2, 3, 4},
|
||||
[]int{1, 2, 3, 4},
|
||||
{1, 2, 3, 4},
|
||||
{1, 2, 3, 4},
|
||||
}},
|
||||
ans23{[]int{1, 1, 2, 2, 3, 3, 4, 4}},
|
||||
},
|
||||
|
||||
question23{
|
||||
{
|
||||
para23{[][]int{
|
||||
[]int{1, 2, 3, 4, 5},
|
||||
[]int{1, 2, 3, 4, 5},
|
||||
{1, 2, 3, 4, 5},
|
||||
{1, 2, 3, 4, 5},
|
||||
}},
|
||||
ans23{[]int{1, 1, 2, 2, 3, 3, 4, 4, 5, 5}},
|
||||
},
|
||||
|
||||
question23{
|
||||
{
|
||||
para23{[][]int{
|
||||
[]int{1},
|
||||
[]int{9, 9, 9, 9, 9},
|
||||
{1},
|
||||
{9, 9, 9, 9, 9},
|
||||
}},
|
||||
ans23{[]int{1, 9, 9, 9, 9, 9}},
|
||||
},
|
||||
|
||||
question23{
|
||||
{
|
||||
para23{[][]int{
|
||||
[]int{9, 9, 9, 9, 9},
|
||||
[]int{1},
|
||||
{9, 9, 9, 9, 9},
|
||||
{1},
|
||||
}},
|
||||
ans23{[]int{1, 9, 9, 9, 9, 9}},
|
||||
},
|
||||
|
||||
question23{
|
||||
{
|
||||
para23{[][]int{
|
||||
[]int{2, 3, 4},
|
||||
[]int{4, 5, 6},
|
||||
{2, 3, 4},
|
||||
{4, 5, 6},
|
||||
}},
|
||||
ans23{[]int{2, 3, 4, 4, 5, 6}},
|
||||
},
|
||||
|
||||
question23{
|
||||
{
|
||||
para23{[][]int{
|
||||
[]int{1, 3, 8},
|
||||
[]int{1, 7},
|
||||
{1, 3, 8},
|
||||
{1, 7},
|
||||
}},
|
||||
ans23{[]int{1, 1, 3, 7, 8}},
|
||||
},
|
||||
|
@ -28,22 +28,22 @@ func Test_Problem24(t *testing.T) {
|
||||
|
||||
qs := []question24{
|
||||
|
||||
question24{
|
||||
{
|
||||
para24{[]int{}},
|
||||
ans24{[]int{}},
|
||||
},
|
||||
|
||||
question24{
|
||||
{
|
||||
para24{[]int{1}},
|
||||
ans24{[]int{1}},
|
||||
},
|
||||
|
||||
question24{
|
||||
{
|
||||
para24{[]int{1, 2, 3, 4}},
|
||||
ans24{[]int{2, 1, 4, 3}},
|
||||
},
|
||||
|
||||
question24{
|
||||
{
|
||||
para24{[]int{1, 2, 3, 4, 5}},
|
||||
ans24{[]int{2, 1, 4, 3, 5}},
|
||||
},
|
||||
|
@ -29,7 +29,7 @@ func Test_Problem25(t *testing.T) {
|
||||
|
||||
qs := []question25{
|
||||
|
||||
question25{
|
||||
{
|
||||
para25{
|
||||
[]int{1, 2, 3, 4, 5},
|
||||
3,
|
||||
@ -37,7 +37,7 @@ func Test_Problem25(t *testing.T) {
|
||||
ans25{[]int{3, 2, 1, 4, 5}},
|
||||
},
|
||||
|
||||
question25{
|
||||
{
|
||||
para25{
|
||||
[]int{1, 2, 3, 4, 5},
|
||||
1,
|
||||
|
@ -26,22 +26,22 @@ func Test_Problem26(t *testing.T) {
|
||||
|
||||
qs := []question26{
|
||||
|
||||
question26{
|
||||
{
|
||||
para26{[]int{1, 1, 2}},
|
||||
ans26{2},
|
||||
},
|
||||
|
||||
question26{
|
||||
{
|
||||
para26{[]int{0, 0, 1, 1, 1, 1, 2, 3, 4, 4}},
|
||||
ans26{5},
|
||||
},
|
||||
|
||||
question26{
|
||||
{
|
||||
para26{[]int{0, 0, 0, 0, 0}},
|
||||
ans26{1},
|
||||
},
|
||||
|
||||
question26{
|
||||
{
|
||||
para26{[]int{1}},
|
||||
ans26{1},
|
||||
},
|
||||
|
@ -27,32 +27,32 @@ func Test_Problem27(t *testing.T) {
|
||||
|
||||
qs := []question27{
|
||||
|
||||
question27{
|
||||
{
|
||||
para27{[]int{1, 0, 1}, 1},
|
||||
ans27{1},
|
||||
},
|
||||
|
||||
question27{
|
||||
{
|
||||
para27{[]int{0, 1, 0, 3, 0, 12}, 0},
|
||||
ans27{3},
|
||||
},
|
||||
|
||||
question27{
|
||||
{
|
||||
para27{[]int{0, 1, 0, 3, 0, 0, 0, 0, 1, 12}, 0},
|
||||
ans27{4},
|
||||
},
|
||||
|
||||
question27{
|
||||
{
|
||||
para27{[]int{0, 0, 0, 0, 0}, 0},
|
||||
ans27{0},
|
||||
},
|
||||
|
||||
question27{
|
||||
{
|
||||
para27{[]int{1}, 1},
|
||||
ans27{0},
|
||||
},
|
||||
|
||||
question27{
|
||||
{
|
||||
para27{[]int{0, 1, 2, 2, 3, 0, 4, 2}, 2},
|
||||
ans27{5},
|
||||
},
|
||||
|
@ -27,32 +27,32 @@ func Test_Problem28(t *testing.T) {
|
||||
|
||||
qs := []question28{
|
||||
|
||||
question28{
|
||||
{
|
||||
para28{"abab", "ab"},
|
||||
ans28{0},
|
||||
},
|
||||
|
||||
question28{
|
||||
{
|
||||
para28{"hello", "ll"},
|
||||
ans28{2},
|
||||
},
|
||||
|
||||
question28{
|
||||
{
|
||||
para28{"", "abc"},
|
||||
ans28{0},
|
||||
},
|
||||
|
||||
question28{
|
||||
{
|
||||
para28{"abacbabc", "abc"},
|
||||
ans28{5},
|
||||
},
|
||||
|
||||
question28{
|
||||
{
|
||||
para28{"abacbabc", "abcd"},
|
||||
ans28{-1},
|
||||
},
|
||||
|
||||
question28{
|
||||
{
|
||||
para28{"abacbabc", ""},
|
||||
ans28{0},
|
||||
},
|
||||
|
@ -27,27 +27,27 @@ func Test_Problem29(t *testing.T) {
|
||||
|
||||
qs := []question29{
|
||||
|
||||
question29{
|
||||
{
|
||||
para29{10, 3},
|
||||
ans29{3},
|
||||
},
|
||||
|
||||
question29{
|
||||
{
|
||||
para29{7, -3},
|
||||
ans29{-2},
|
||||
},
|
||||
|
||||
question29{
|
||||
{
|
||||
para29{-1, 1},
|
||||
ans29{-1},
|
||||
},
|
||||
|
||||
question29{
|
||||
{
|
||||
para29{1, -1},
|
||||
ans29{-1},
|
||||
},
|
||||
|
||||
question29{
|
||||
{
|
||||
para29{2147483647, 3},
|
||||
ans29{715827882},
|
||||
},
|
||||
|
@ -27,57 +27,57 @@ func Test_Problem30(t *testing.T) {
|
||||
|
||||
qs := []question30{
|
||||
|
||||
question30{
|
||||
{
|
||||
para30{"aaaaaaaa", []string{"aa", "aa", "aa"}},
|
||||
ans30{[]int{0, 1, 2}},
|
||||
},
|
||||
|
||||
question30{
|
||||
{
|
||||
para30{"barfoothefoobarman", []string{"foo", "bar"}},
|
||||
ans30{[]int{0, 9}},
|
||||
},
|
||||
|
||||
question30{
|
||||
{
|
||||
para30{"wordgoodgoodgoodbestword", []string{"word", "good", "best", "word"}},
|
||||
ans30{[]int{}},
|
||||
},
|
||||
|
||||
question30{
|
||||
{
|
||||
para30{"goodgoodgoodgoodgood", []string{"good"}},
|
||||
ans30{[]int{0, 4, 8, 12, 16}},
|
||||
},
|
||||
|
||||
question30{
|
||||
{
|
||||
para30{"barofoothefoolbarman", []string{"foo", "bar"}},
|
||||
ans30{[]int{}},
|
||||
},
|
||||
|
||||
question30{
|
||||
{
|
||||
para30{"bbarffoothefoobarman", []string{"foo", "bar"}},
|
||||
ans30{[]int{}},
|
||||
},
|
||||
|
||||
question30{
|
||||
{
|
||||
para30{"ooroodoofoodtoo", []string{"foo", "doo", "roo", "tee", "oo"}},
|
||||
ans30{[]int{}},
|
||||
},
|
||||
|
||||
question30{
|
||||
{
|
||||
para30{"abc", []string{"a", "b", "c"}},
|
||||
ans30{[]int{0}},
|
||||
},
|
||||
|
||||
question30{
|
||||
{
|
||||
para30{"a", []string{"b"}},
|
||||
ans30{[]int{}},
|
||||
},
|
||||
|
||||
question30{
|
||||
{
|
||||
para30{"ab", []string{"ba"}},
|
||||
ans30{[]int{}},
|
||||
},
|
||||
|
||||
question30{
|
||||
{
|
||||
para30{"n", []string{}},
|
||||
ans30{[]int{}},
|
||||
},
|
||||
|
@ -27,17 +27,17 @@ func Test_Problem33(t *testing.T) {
|
||||
|
||||
qs := []question33{
|
||||
|
||||
question33{
|
||||
{
|
||||
para33{[]int{3, 1}, 1},
|
||||
ans33{1},
|
||||
},
|
||||
|
||||
question33{
|
||||
{
|
||||
para33{[]int{4, 5, 6, 7, 0, 1, 2}, 0},
|
||||
ans33{4},
|
||||
},
|
||||
|
||||
question33{
|
||||
{
|
||||
para33{[]int{4, 5, 6, 7, 0, 1, 2}, 3},
|
||||
ans33{-1},
|
||||
},
|
||||
|
@ -27,12 +27,12 @@ func Test_Problem34(t *testing.T) {
|
||||
|
||||
qs := []question34{
|
||||
|
||||
question34{
|
||||
{
|
||||
para34{[]int{5, 7, 7, 8, 8, 10}, 8},
|
||||
ans34{[]int{3, 4}},
|
||||
},
|
||||
|
||||
question34{
|
||||
{
|
||||
para34{[]int{5, 7, 7, 8, 8, 10}, 6},
|
||||
ans34{[]int{-1, -1}},
|
||||
},
|
||||
|
@ -27,22 +27,22 @@ func Test_Problem35(t *testing.T) {
|
||||
|
||||
qs := []question35{
|
||||
|
||||
question35{
|
||||
{
|
||||
para35{[]int{1, 3, 5, 6}, 5},
|
||||
ans35{2},
|
||||
},
|
||||
|
||||
question35{
|
||||
{
|
||||
para35{[]int{1, 3, 5, 6}, 2},
|
||||
ans35{1},
|
||||
},
|
||||
|
||||
question35{
|
||||
{
|
||||
para35{[]int{1, 3, 5, 6}, 7},
|
||||
ans35{4},
|
||||
},
|
||||
|
||||
question35{
|
||||
{
|
||||
para35{[]int{1, 3, 5, 6}, 0},
|
||||
ans35{0},
|
||||
},
|
||||
|
@ -26,45 +26,45 @@ func Test_Problem36(t *testing.T) {
|
||||
|
||||
qs := []question36{
|
||||
|
||||
question36{
|
||||
{
|
||||
para36{[][]byte{
|
||||
[]byte{'5', '3', '.', '.', '7', '.', '.', '.', '.'},
|
||||
[]byte{'6', '.', '.', '1', '9', '5', '.', '.', '.'},
|
||||
[]byte{'.', '9', '8', '.', '.', '.', '.', '6', '.'},
|
||||
[]byte{'8', '.', '.', '.', '6', '.', '.', '.', '3'},
|
||||
[]byte{'4', '.', '.', '8', '.', '3', '.', '.', '1'},
|
||||
[]byte{'7', '.', '.', '.', '2', '.', '.', '.', '6'},
|
||||
[]byte{'.', '6', '.', '.', '.', '.', '2', '8', '.'},
|
||||
[]byte{'.', '.', '.', '4', '1', '9', '.', '.', '5'},
|
||||
[]byte{'.', '.', '.', '.', '8', '.', '.', '7', '9'}}},
|
||||
{'5', '3', '.', '.', '7', '.', '.', '.', '.'},
|
||||
{'6', '.', '.', '1', '9', '5', '.', '.', '.'},
|
||||
{'.', '9', '8', '.', '.', '.', '.', '6', '.'},
|
||||
{'8', '.', '.', '.', '6', '.', '.', '.', '3'},
|
||||
{'4', '.', '.', '8', '.', '3', '.', '.', '1'},
|
||||
{'7', '.', '.', '.', '2', '.', '.', '.', '6'},
|
||||
{'.', '6', '.', '.', '.', '.', '2', '8', '.'},
|
||||
{'.', '.', '.', '4', '1', '9', '.', '.', '5'},
|
||||
{'.', '.', '.', '.', '8', '.', '.', '7', '9'}}},
|
||||
ans36{true},
|
||||
},
|
||||
|
||||
question36{
|
||||
{
|
||||
para36{[][]byte{
|
||||
[]byte{'8', '3', '.', '.', '7', '.', '.', '.', '.'},
|
||||
[]byte{'6', '.', '.', '1', '9', '5', '.', '.', '.'},
|
||||
[]byte{'.', '9', '8', '.', '.', '.', '.', '6', '.'},
|
||||
[]byte{'8', '.', '.', '.', '6', '.', '.', '.', '3'},
|
||||
[]byte{'4', '.', '.', '8', '.', '3', '.', '.', '1'},
|
||||
[]byte{'7', '.', '.', '.', '2', '.', '.', '.', '6'},
|
||||
[]byte{'.', '6', '.', '.', '.', '.', '2', '8', '.'},
|
||||
[]byte{'.', '.', '.', '4', '1', '9', '.', '.', '5'},
|
||||
[]byte{'.', '.', '.', '.', '8', '.', '.', '7', '9'}}},
|
||||
{'8', '3', '.', '.', '7', '.', '.', '.', '.'},
|
||||
{'6', '.', '.', '1', '9', '5', '.', '.', '.'},
|
||||
{'.', '9', '8', '.', '.', '.', '.', '6', '.'},
|
||||
{'8', '.', '.', '.', '6', '.', '.', '.', '3'},
|
||||
{'4', '.', '.', '8', '.', '3', '.', '.', '1'},
|
||||
{'7', '.', '.', '.', '2', '.', '.', '.', '6'},
|
||||
{'.', '6', '.', '.', '.', '.', '2', '8', '.'},
|
||||
{'.', '.', '.', '4', '1', '9', '.', '.', '5'},
|
||||
{'.', '.', '.', '.', '8', '.', '.', '7', '9'}}},
|
||||
ans36{false},
|
||||
},
|
||||
|
||||
question36{
|
||||
{
|
||||
para36{[][]byte{
|
||||
[]byte{'.', '8', '7', '6', '5', '4', '3', '2', '1'},
|
||||
[]byte{'2', '.', '.', '.', '.', '.', '.', '.', '.'},
|
||||
[]byte{'3', '.', '.', '.', '.', '.', '.', '.', '.'},
|
||||
[]byte{'4', '.', '.', '.', '.', '.', '.', '.', '.'},
|
||||
[]byte{'5', '.', '.', '.', '.', '.', '.', '.', '.'},
|
||||
[]byte{'6', '.', '.', '.', '.', '.', '.', '.', '.'},
|
||||
[]byte{'7', '.', '.', '.', '.', '.', '.', '.', '.'},
|
||||
[]byte{'8', '.', '.', '.', '.', '.', '.', '.', '.'},
|
||||
[]byte{'9', '.', '.', '.', '.', '.', '.', '.', '.'}}},
|
||||
{'.', '8', '7', '6', '5', '4', '3', '2', '1'},
|
||||
{'2', '.', '.', '.', '.', '.', '.', '.', '.'},
|
||||
{'3', '.', '.', '.', '.', '.', '.', '.', '.'},
|
||||
{'4', '.', '.', '.', '.', '.', '.', '.', '.'},
|
||||
{'5', '.', '.', '.', '.', '.', '.', '.', '.'},
|
||||
{'6', '.', '.', '.', '.', '.', '.', '.', '.'},
|
||||
{'7', '.', '.', '.', '.', '.', '.', '.', '.'},
|
||||
{'8', '.', '.', '.', '.', '.', '.', '.', '.'},
|
||||
{'9', '.', '.', '.', '.', '.', '.', '.', '.'}}},
|
||||
ans36{true},
|
||||
},
|
||||
}
|
||||
|
@ -26,27 +26,27 @@ func Test_Problem37(t *testing.T) {
|
||||
|
||||
qs := []question37{
|
||||
|
||||
question37{
|
||||
{
|
||||
para37{[][]byte{
|
||||
[]byte{'5', '3', '.', '.', '7', '.', '.', '.', '.'},
|
||||
[]byte{'6', '.', '.', '1', '9', '5', '.', '.', '.'},
|
||||
[]byte{'.', '9', '8', '.', '.', '.', '.', '6', '.'},
|
||||
[]byte{'8', '.', '.', '.', '6', '.', '.', '.', '3'},
|
||||
[]byte{'4', '.', '.', '8', '.', '3', '.', '.', '1'},
|
||||
[]byte{'7', '.', '.', '.', '2', '.', '.', '.', '6'},
|
||||
[]byte{'.', '6', '.', '.', '.', '.', '2', '8', '.'},
|
||||
[]byte{'.', '.', '.', '4', '1', '9', '.', '.', '5'},
|
||||
[]byte{'.', '.', '.', '.', '8', '.', '.', '7', '9'}}},
|
||||
{'5', '3', '.', '.', '7', '.', '.', '.', '.'},
|
||||
{'6', '.', '.', '1', '9', '5', '.', '.', '.'},
|
||||
{'.', '9', '8', '.', '.', '.', '.', '6', '.'},
|
||||
{'8', '.', '.', '.', '6', '.', '.', '.', '3'},
|
||||
{'4', '.', '.', '8', '.', '3', '.', '.', '1'},
|
||||
{'7', '.', '.', '.', '2', '.', '.', '.', '6'},
|
||||
{'.', '6', '.', '.', '.', '.', '2', '8', '.'},
|
||||
{'.', '.', '.', '4', '1', '9', '.', '.', '5'},
|
||||
{'.', '.', '.', '.', '8', '.', '.', '7', '9'}}},
|
||||
ans37{[][]byte{
|
||||
[]byte{'5', '3', '4', '6', '7', '8', '9', '1', '2'},
|
||||
[]byte{'6', '7', '2', '1', '9', '5', '3', '4', '8'},
|
||||
[]byte{'1', '9', '8', '3', '4', '2', '5', '6', '7'},
|
||||
[]byte{'8', '5', '9', '7', '6', '1', '4', '2', '3'},
|
||||
[]byte{'4', '2', '6', '8', '5', '3', '7', '9', '1'},
|
||||
[]byte{'7', '1', '3', '9', '2', '4', '8', '5', '6'},
|
||||
[]byte{'9', '6', '1', '5', '3', '7', '2', '8', '4'},
|
||||
[]byte{'2', '8', '7', '4', '1', '9', '6', '3', '5'},
|
||||
[]byte{'3', '4', '5', '2', '8', '6', '1', '7', '9'}}},
|
||||
{'5', '3', '4', '6', '7', '8', '9', '1', '2'},
|
||||
{'6', '7', '2', '1', '9', '5', '3', '4', '8'},
|
||||
{'1', '9', '8', '3', '4', '2', '5', '6', '7'},
|
||||
{'8', '5', '9', '7', '6', '1', '4', '2', '3'},
|
||||
{'4', '2', '6', '8', '5', '3', '7', '9', '1'},
|
||||
{'7', '1', '3', '9', '2', '4', '8', '5', '6'},
|
||||
{'9', '6', '1', '5', '3', '7', '2', '8', '4'},
|
||||
{'2', '8', '7', '4', '1', '9', '6', '3', '5'},
|
||||
{'3', '4', '5', '2', '8', '6', '1', '7', '9'}}},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -27,14 +27,14 @@ func Test_Problem39(t *testing.T) {
|
||||
|
||||
qs := []question39{
|
||||
|
||||
question39{
|
||||
{
|
||||
para39{[]int{2, 3, 6, 7}, 7},
|
||||
ans39{[][]int{[]int{7}, []int{2, 2, 3}}},
|
||||
ans39{[][]int{{7}, {2, 2, 3}}},
|
||||
},
|
||||
|
||||
question39{
|
||||
{
|
||||
para39{[]int{2, 3, 5}, 8},
|
||||
ans39{[][]int{[]int{2, 2, 2, 2}, []int{2, 3, 3}, []int{3, 5}}},
|
||||
ans39{[][]int{{2, 2, 2, 2}, {2, 3, 3}, {3, 5}}},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -27,14 +27,14 @@ func Test_Problem40(t *testing.T) {
|
||||
|
||||
qs := []question40{
|
||||
|
||||
question40{
|
||||
{
|
||||
para40{[]int{10, 1, 2, 7, 6, 1, 5}, 8},
|
||||
ans40{[][]int{[]int{1, 7}, []int{1, 2, 5}, []int{2, 6}, []int{1, 1, 6}}},
|
||||
ans40{[][]int{{1, 7}, {1, 2, 5}, {2, 6}, {1, 1, 6}}},
|
||||
},
|
||||
|
||||
question40{
|
||||
{
|
||||
para40{[]int{2, 5, 2, 1, 2}, 5},
|
||||
ans40{[][]int{[]int{1, 2, 2}, []int{5}}},
|
||||
ans40{[][]int{{1, 2, 2}, {5}}},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -26,37 +26,37 @@ func Test_Problem41(t *testing.T) {
|
||||
|
||||
qs := []question41{
|
||||
|
||||
question41{
|
||||
{
|
||||
para41{[]int{10, -1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, -3}},
|
||||
ans41{6},
|
||||
},
|
||||
|
||||
question41{
|
||||
{
|
||||
para41{[]int{10, -1, 8, 6, 7, 3, -2, 5, 4, 2, 1, -3}},
|
||||
ans41{9},
|
||||
},
|
||||
|
||||
question41{
|
||||
{
|
||||
para41{[]int{1}},
|
||||
ans41{2},
|
||||
},
|
||||
|
||||
question41{
|
||||
{
|
||||
para41{[]int{0, 2, 2, 1, 1}},
|
||||
ans41{3},
|
||||
},
|
||||
|
||||
question41{
|
||||
{
|
||||
para41{[]int{}},
|
||||
ans41{1},
|
||||
},
|
||||
|
||||
question41{
|
||||
{
|
||||
para41{[]int{1, 2, 0}},
|
||||
ans41{3},
|
||||
},
|
||||
|
||||
question41{
|
||||
{
|
||||
para41{[]int{3, 4, -1, 1}},
|
||||
ans41{2},
|
||||
},
|
||||
|
@ -26,7 +26,7 @@ func Test_Problem42(t *testing.T) {
|
||||
|
||||
qs := []question42{
|
||||
|
||||
question42{
|
||||
{
|
||||
para42{[]int{0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1}},
|
||||
ans42{6},
|
||||
},
|
||||
|
@ -26,9 +26,9 @@ func Test_Problem46(t *testing.T) {
|
||||
|
||||
qs := []question46{
|
||||
|
||||
question46{
|
||||
{
|
||||
para46{[]int{1, 2, 3}},
|
||||
ans46{[][]int{[]int{1, 2, 3}, []int{1, 3, 2}, []int{2, 1, 3}, []int{2, 3, 1}, []int{3, 1, 2}, []int{3, 2, 1}}},
|
||||
ans46{[][]int{{1, 2, 3}, {1, 3, 2}, {2, 1, 3}, {2, 3, 1}, {3, 1, 2}, {3, 2, 1}}},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -26,19 +26,19 @@ func Test_Problem47(t *testing.T) {
|
||||
|
||||
qs := []question47{
|
||||
|
||||
question47{
|
||||
{
|
||||
para47{[]int{1, 1, 2}},
|
||||
ans47{[][]int{[]int{1, 1, 2}, []int{1, 2, 1}, []int{2, 1, 1}}},
|
||||
ans47{[][]int{{1, 1, 2}, {1, 2, 1}, {2, 1, 1}}},
|
||||
},
|
||||
|
||||
question47{
|
||||
{
|
||||
para47{[]int{1, 2, 2}},
|
||||
ans47{[][]int{[]int{1, 2, 2}, []int{2, 2, 1}, []int{2, 1, 2}}},
|
||||
ans47{[][]int{{1, 2, 2}, {2, 2, 1}, {2, 1, 2}}},
|
||||
},
|
||||
|
||||
question47{
|
||||
{
|
||||
para47{[]int{2, 2, 2}},
|
||||
ans47{[][]int{[]int{2, 2, 2}}},
|
||||
ans47{[][]int{{2, 2, 2}}},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -26,14 +26,14 @@ func Test_Problem48(t *testing.T) {
|
||||
|
||||
qs := []question48{
|
||||
|
||||
question48{
|
||||
para48{[][]int{[]int{1, 2, 3}, []int{4, 5, 6}, []int{7, 8, 9}}},
|
||||
ans48{[][]int{[]int{7, 4, 1}, []int{8, 5, 2}, []int{9, 6, 3}}},
|
||||
{
|
||||
para48{[][]int{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}},
|
||||
ans48{[][]int{{7, 4, 1}, {8, 5, 2}, {9, 6, 3}}},
|
||||
},
|
||||
|
||||
question48{
|
||||
para48{[][]int{[]int{5, 1, 9, 11}, []int{2, 4, 8, 10}, []int{13, 3, 6, 7}, []int{15, 14, 12, 16}}},
|
||||
ans48{[][]int{[]int{15, 13, 2, 5}, []int{14, 3, 4, 1}, []int{12, 6, 8, 9}, []int{16, 7, 10, 11}}},
|
||||
{
|
||||
para48{[][]int{{5, 1, 9, 11}, {2, 4, 8, 10}, {13, 3, 6, 7}, {15, 14, 12, 16}}},
|
||||
ans48{[][]int{{15, 13, 2, 5}, {14, 3, 4, 1}, {12, 6, 8, 9}, {16, 7, 10, 11}}},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -26,9 +26,9 @@ func Test_Problem49(t *testing.T) {
|
||||
|
||||
qs := []question49{
|
||||
|
||||
question49{
|
||||
{
|
||||
para49{[]string{"eat", "tea", "tan", "ate", "nat", "bat"}},
|
||||
ans49{[][]string{[]string{"ate", "eat", "tea"}, []string{"nat", "tan"}, []string{"bat"}}},
|
||||
ans49{[][]string{{"ate", "eat", "tea"}, {"nat", "tan"}, {"bat"}}},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -27,17 +27,17 @@ func Test_Problem50(t *testing.T) {
|
||||
|
||||
qs := []question50{
|
||||
|
||||
question50{
|
||||
{
|
||||
para50{2.00000, 10},
|
||||
ans50{1024.00000},
|
||||
},
|
||||
|
||||
question50{
|
||||
{
|
||||
para50{2.10000, 3},
|
||||
ans50{9.26100},
|
||||
},
|
||||
|
||||
question50{
|
||||
{
|
||||
para50{2.00000, -2},
|
||||
ans50{0.25000},
|
||||
},
|
||||
|
@ -26,14 +26,14 @@ func Test_Problem51(t *testing.T) {
|
||||
|
||||
qs := []question51{
|
||||
|
||||
question51{
|
||||
{
|
||||
para51{4},
|
||||
ans51{[][]string{
|
||||
[]string{".Q..",
|
||||
{".Q..",
|
||||
"...Q",
|
||||
"Q...",
|
||||
"..Q."},
|
||||
[]string{"..Q.",
|
||||
{"..Q.",
|
||||
"Q...",
|
||||
"...Q",
|
||||
".Q.."},
|
||||
|
@ -26,51 +26,51 @@ func Test_Problem52(t *testing.T) {
|
||||
|
||||
qs := []question52{
|
||||
|
||||
question52{
|
||||
{
|
||||
para52{1},
|
||||
ans52{1},
|
||||
},
|
||||
|
||||
question52{
|
||||
{
|
||||
para52{2},
|
||||
ans52{0},
|
||||
},
|
||||
question52{
|
||||
{
|
||||
para52{3},
|
||||
ans52{0},
|
||||
},
|
||||
|
||||
question52{
|
||||
{
|
||||
para52{4},
|
||||
ans52{2},
|
||||
},
|
||||
|
||||
question52{
|
||||
{
|
||||
para52{5},
|
||||
ans52{10},
|
||||
},
|
||||
|
||||
question52{
|
||||
{
|
||||
para52{6},
|
||||
ans52{4},
|
||||
},
|
||||
|
||||
question52{
|
||||
{
|
||||
para52{7},
|
||||
ans52{40},
|
||||
},
|
||||
|
||||
question52{
|
||||
{
|
||||
para52{8},
|
||||
ans52{92},
|
||||
},
|
||||
|
||||
question52{
|
||||
{
|
||||
para52{9},
|
||||
ans52{352},
|
||||
},
|
||||
|
||||
question52{
|
||||
{
|
||||
para52{10},
|
||||
ans52{724},
|
||||
},
|
||||
|
@ -26,21 +26,21 @@ func Test_Problem53(t *testing.T) {
|
||||
|
||||
qs := []question53{
|
||||
|
||||
question53{
|
||||
{
|
||||
para53{[]int{-2, 1, -3, 4, -1, 2, 1, -5, 4}},
|
||||
ans53{6},
|
||||
},
|
||||
question53{
|
||||
{
|
||||
para53{[]int{2, 7, 9, 3, 1}},
|
||||
ans53{22},
|
||||
},
|
||||
|
||||
question53{
|
||||
{
|
||||
para53{[]int{2}},
|
||||
ans53{2},
|
||||
},
|
||||
|
||||
question53{
|
||||
{
|
||||
para53{[]int{-1, -2}},
|
||||
ans53{-1},
|
||||
},
|
||||
|
@ -19,10 +19,10 @@ func spiralOrder(matrix [][]int) []int {
|
||||
return res
|
||||
}
|
||||
visit, m, n, round, x, y, spDir := make([][]int, len(matrix)), len(matrix), len(matrix[0]), 0, 0, 0, [][]int{
|
||||
[]int{0, 1}, // 朝右
|
||||
[]int{1, 0}, // 朝下
|
||||
[]int{0, -1}, // 朝左
|
||||
[]int{-1, 0}, // 朝上
|
||||
{0, 1}, // 朝右
|
||||
{1, 0}, // 朝下
|
||||
{0, -1}, // 朝左
|
||||
{-1, 0}, // 朝上
|
||||
}
|
||||
for i := 0; i < m; i++ {
|
||||
visit[i] = make([]int, n)
|
||||
|
@ -26,27 +26,27 @@ func Test_Problem54(t *testing.T) {
|
||||
|
||||
qs := []question54{
|
||||
|
||||
question54{
|
||||
para54{[][]int{[]int{3}, []int{2}}},
|
||||
{
|
||||
para54{[][]int{{3}, {2}}},
|
||||
ans54{[]int{3, 2}},
|
||||
},
|
||||
|
||||
question54{
|
||||
para54{[][]int{[]int{2, 3}}},
|
||||
{
|
||||
para54{[][]int{{2, 3}}},
|
||||
ans54{[]int{2, 3}},
|
||||
},
|
||||
|
||||
question54{
|
||||
para54{[][]int{[]int{1}}},
|
||||
{
|
||||
para54{[][]int{{1}}},
|
||||
ans54{[]int{1}},
|
||||
},
|
||||
|
||||
question54{
|
||||
para54{[][]int{[]int{1, 2, 3}, []int{4, 5, 6}, []int{7, 8, 9}}},
|
||||
{
|
||||
para54{[][]int{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}},
|
||||
ans54{[]int{1, 2, 3, 6, 9, 8, 7, 4, 5}},
|
||||
},
|
||||
question54{
|
||||
para54{[][]int{[]int{1, 2, 3, 4}, []int{5, 6, 7, 8}, []int{9, 10, 11, 12}}},
|
||||
{
|
||||
para54{[][]int{{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}}},
|
||||
ans54{[]int{1, 2, 3, 4, 8, 12, 11, 10, 9, 5, 6, 7}},
|
||||
},
|
||||
}
|
||||
|
@ -26,11 +26,11 @@ func Test_Problem55(t *testing.T) {
|
||||
|
||||
qs := []question55{
|
||||
|
||||
question55{
|
||||
{
|
||||
para55{[]int{2, 3, 1, 1, 4}},
|
||||
ans55{true},
|
||||
},
|
||||
question55{
|
||||
{
|
||||
para55{[]int{3, 2, 1, 0, 4}},
|
||||
ans55{false},
|
||||
},
|
||||
|
@ -26,39 +26,39 @@ func Test_Problem56(t *testing.T) {
|
||||
|
||||
qs := []question56{
|
||||
|
||||
question56{
|
||||
{
|
||||
para56{[]Interval{}},
|
||||
ans56{[]Interval{}},
|
||||
},
|
||||
|
||||
question56{
|
||||
para56{[]Interval{Interval{Start: 1, End: 3}, Interval{Start: 2, End: 6}, Interval{Start: 8, End: 10}, Interval{Start: 15, End: 18}}},
|
||||
ans56{[]Interval{Interval{Start: 1, End: 6}, Interval{Start: 8, End: 10}, Interval{Start: 15, End: 18}}},
|
||||
{
|
||||
para56{[]Interval{{Start: 1, End: 3}, {Start: 2, End: 6}, {Start: 8, End: 10}, {Start: 15, End: 18}}},
|
||||
ans56{[]Interval{{Start: 1, End: 6}, {Start: 8, End: 10}, {Start: 15, End: 18}}},
|
||||
},
|
||||
|
||||
question56{
|
||||
para56{[]Interval{Interval{Start: 1, End: 4}, Interval{Start: 4, End: 5}}},
|
||||
ans56{[]Interval{Interval{Start: 1, End: 5}}},
|
||||
{
|
||||
para56{[]Interval{{Start: 1, End: 4}, {Start: 4, End: 5}}},
|
||||
ans56{[]Interval{{Start: 1, End: 5}}},
|
||||
},
|
||||
|
||||
question56{
|
||||
para56{[]Interval{Interval{Start: 1, End: 3}, Interval{Start: 3, End: 6}, Interval{Start: 5, End: 10}, Interval{Start: 9, End: 18}}},
|
||||
ans56{[]Interval{Interval{Start: 1, End: 18}}},
|
||||
{
|
||||
para56{[]Interval{{Start: 1, End: 3}, {Start: 3, End: 6}, {Start: 5, End: 10}, {Start: 9, End: 18}}},
|
||||
ans56{[]Interval{{Start: 1, End: 18}}},
|
||||
},
|
||||
|
||||
question56{
|
||||
para56{[]Interval{Interval{Start: 15, End: 18}, Interval{Start: 8, End: 10}, Interval{Start: 2, End: 6}, Interval{Start: 1, End: 3}}},
|
||||
ans56{[]Interval{Interval{Start: 1, End: 6}, Interval{Start: 8, End: 10}, Interval{Start: 15, End: 18}}},
|
||||
{
|
||||
para56{[]Interval{{Start: 15, End: 18}, {Start: 8, End: 10}, {Start: 2, End: 6}, {Start: 1, End: 3}}},
|
||||
ans56{[]Interval{{Start: 1, End: 6}, {Start: 8, End: 10}, {Start: 15, End: 18}}},
|
||||
},
|
||||
|
||||
question56{
|
||||
para56{[]Interval{Interval{Start: 1, End: 3}, Interval{Start: 2, End: 6}, Interval{Start: 8, End: 10}, Interval{Start: 15, End: 18}}},
|
||||
ans56{[]Interval{Interval{Start: 1, End: 6}, Interval{Start: 8, End: 10}, Interval{Start: 15, End: 18}}},
|
||||
{
|
||||
para56{[]Interval{{Start: 1, End: 3}, {Start: 2, End: 6}, {Start: 8, End: 10}, {Start: 15, End: 18}}},
|
||||
ans56{[]Interval{{Start: 1, End: 6}, {Start: 8, End: 10}, {Start: 15, End: 18}}},
|
||||
},
|
||||
|
||||
question56{
|
||||
para56{[]Interval{Interval{Start: 1, End: 4}, Interval{Start: 1, End: 5}}},
|
||||
ans56{[]Interval{Interval{Start: 1, End: 5}}},
|
||||
{
|
||||
para56{[]Interval{{Start: 1, End: 4}, {Start: 1, End: 5}}},
|
||||
ans56{[]Interval{{Start: 1, End: 5}}},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -27,34 +27,34 @@ func Test_Problem57(t *testing.T) {
|
||||
|
||||
qs := []question57{
|
||||
|
||||
question57{
|
||||
{
|
||||
para57{[]Interval{}, Interval{}},
|
||||
ans57{[]Interval{}},
|
||||
},
|
||||
|
||||
question57{
|
||||
para57{[]Interval{Interval{Start: 1, End: 3}, Interval{Start: 6, End: 9}}, Interval{Start: 4, End: 8}},
|
||||
ans57{[]Interval{Interval{Start: 1, End: 5}, Interval{Start: 6, End: 9}}},
|
||||
{
|
||||
para57{[]Interval{{Start: 1, End: 3}, {Start: 6, End: 9}}, Interval{Start: 4, End: 8}},
|
||||
ans57{[]Interval{{Start: 1, End: 5}, {Start: 6, End: 9}}},
|
||||
},
|
||||
|
||||
question57{
|
||||
para57{[]Interval{Interval{Start: 1, End: 3}, Interval{Start: 6, End: 9}}, Interval{Start: 2, End: 5}},
|
||||
ans57{[]Interval{Interval{Start: 1, End: 5}, Interval{Start: 6, End: 9}}},
|
||||
{
|
||||
para57{[]Interval{{Start: 1, End: 3}, {Start: 6, End: 9}}, Interval{Start: 2, End: 5}},
|
||||
ans57{[]Interval{{Start: 1, End: 5}, {Start: 6, End: 9}}},
|
||||
},
|
||||
|
||||
question57{
|
||||
para57{[]Interval{Interval{Start: 1, End: 2}, Interval{Start: 3, End: 5}, Interval{Start: 6, End: 7}, Interval{Start: 8, End: 10}, Interval{Start: 12, End: 16}}, Interval{Start: 4, End: 8}},
|
||||
ans57{[]Interval{Interval{Start: 1, End: 2}, Interval{Start: 3, End: 10}, Interval{Start: 12, End: 16}}},
|
||||
{
|
||||
para57{[]Interval{{Start: 1, End: 2}, {Start: 3, End: 5}, {Start: 6, End: 7}, {Start: 8, End: 10}, {Start: 12, End: 16}}, Interval{Start: 4, End: 8}},
|
||||
ans57{[]Interval{{Start: 1, End: 2}, {Start: 3, End: 10}, {Start: 12, End: 16}}},
|
||||
},
|
||||
|
||||
question57{
|
||||
para57{[]Interval{Interval{Start: 1, End: 5}}, Interval{Start: 5, End: 7}},
|
||||
ans57{[]Interval{Interval{Start: 1, End: 7}}},
|
||||
{
|
||||
para57{[]Interval{{Start: 1, End: 5}}, Interval{Start: 5, End: 7}},
|
||||
ans57{[]Interval{{Start: 1, End: 7}}},
|
||||
},
|
||||
|
||||
question57{
|
||||
para57{[]Interval{Interval{Start: 1, End: 2}, Interval{Start: 3, End: 5}, Interval{Start: 6, End: 7}, Interval{Start: 8, End: 10}, Interval{Start: 12, End: 16}}, Interval{Start: 9, End: 12}},
|
||||
ans57{[]Interval{Interval{Start: 1, End: 2}, Interval{Start: 3, End: 5}, Interval{Start: 6, End: 7}, Interval{Start: 8, End: 16}}},
|
||||
{
|
||||
para57{[]Interval{{Start: 1, End: 2}, {Start: 3, End: 5}, {Start: 6, End: 7}, {Start: 8, End: 10}, {Start: 12, End: 16}}, Interval{Start: 9, End: 12}},
|
||||
ans57{[]Interval{{Start: 1, End: 2}, {Start: 3, End: 5}, {Start: 6, End: 7}, {Start: 8, End: 16}}},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -5,13 +5,13 @@ func generateMatrix(n int) [][]int {
|
||||
return [][]int{}
|
||||
}
|
||||
if n == 1 {
|
||||
return [][]int{[]int{1}}
|
||||
return [][]int{{1}}
|
||||
}
|
||||
res, visit, round, x, y, spDir := make([][]int, n), make([][]int, n), 0, 0, 0, [][]int{
|
||||
[]int{0, 1}, // 朝右
|
||||
[]int{1, 0}, // 朝下
|
||||
[]int{0, -1}, // 朝左
|
||||
[]int{-1, 0}, // 朝上
|
||||
{0, 1}, // 朝右
|
||||
{1, 0}, // 朝下
|
||||
{0, -1}, // 朝左
|
||||
{-1, 0}, // 朝上
|
||||
}
|
||||
for i := 0; i < n; i++ {
|
||||
visit[i] = make([]int, n)
|
||||
|
@ -26,14 +26,14 @@ func Test_Problem59(t *testing.T) {
|
||||
|
||||
qs := []question59{
|
||||
|
||||
question59{
|
||||
{
|
||||
para59{3},
|
||||
ans59{[][]int{[]int{1, 2, 3}, []int{8, 9, 4}, []int{7, 6, 5}}},
|
||||
ans59{[][]int{{1, 2, 3}, {8, 9, 4}, {7, 6, 5}}},
|
||||
},
|
||||
|
||||
question59{
|
||||
{
|
||||
para59{4},
|
||||
ans59{[][]int{[]int{1, 2, 3, 4}, []int{12, 13, 14, 5}, []int{11, 16, 15, 6}, []int{10, 9, 8, 7}}},
|
||||
ans59{[][]int{{1, 2, 3, 4}, {12, 13, 14, 5}, {11, 16, 15, 6}, {10, 9, 8, 7}}},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -27,12 +27,12 @@ func Test_Problem60(t *testing.T) {
|
||||
|
||||
qs := []question60{
|
||||
|
||||
question60{
|
||||
{
|
||||
para60{3, 3},
|
||||
ans60{"213"},
|
||||
},
|
||||
|
||||
question60{
|
||||
{
|
||||
para60{4, 9},
|
||||
ans60{"2314"},
|
||||
},
|
||||
|
@ -29,32 +29,32 @@ func Test_Problem61(t *testing.T) {
|
||||
|
||||
qs := []question61{
|
||||
|
||||
question61{
|
||||
{
|
||||
para61{[]int{1, 2, 3, 4, 5}, 2},
|
||||
ans61{[]int{4, 5, 1, 2, 3}},
|
||||
},
|
||||
|
||||
question61{
|
||||
{
|
||||
para61{[]int{1, 2, 3, 4, 5}, 3},
|
||||
ans61{[]int{4, 5, 1, 2, 3}},
|
||||
},
|
||||
|
||||
question61{
|
||||
{
|
||||
para61{[]int{0, 1, 2}, 4},
|
||||
ans61{[]int{2, 0, 1}},
|
||||
},
|
||||
|
||||
question61{
|
||||
{
|
||||
para61{[]int{1, 1, 1, 2}, 3},
|
||||
ans61{[]int{1, 1, 2, 1}},
|
||||
},
|
||||
|
||||
question61{
|
||||
{
|
||||
para61{[]int{1}, 10},
|
||||
ans61{[]int{1}},
|
||||
},
|
||||
|
||||
question61{
|
||||
{
|
||||
para61{[]int{}, 100},
|
||||
ans61{[]int{}},
|
||||
},
|
||||
|
@ -27,17 +27,17 @@ func Test_Problem62(t *testing.T) {
|
||||
|
||||
qs := []question62{
|
||||
|
||||
question62{
|
||||
{
|
||||
para62{3, 2},
|
||||
ans62{3},
|
||||
},
|
||||
|
||||
question62{
|
||||
{
|
||||
para62{7, 3},
|
||||
ans62{28},
|
||||
},
|
||||
|
||||
question62{
|
||||
{
|
||||
para62{1, 2},
|
||||
ans62{1},
|
||||
},
|
||||
|
@ -26,29 +26,29 @@ func Test_Problem63(t *testing.T) {
|
||||
|
||||
qs := []question63{
|
||||
|
||||
question63{
|
||||
{
|
||||
para63{[][]int{
|
||||
[]int{0, 0, 0},
|
||||
[]int{0, 1, 0},
|
||||
[]int{0, 0, 0},
|
||||
{0, 0, 0},
|
||||
{0, 1, 0},
|
||||
{0, 0, 0},
|
||||
}},
|
||||
ans63{2},
|
||||
},
|
||||
|
||||
question63{
|
||||
{
|
||||
para63{[][]int{
|
||||
[]int{0, 0},
|
||||
[]int{1, 1},
|
||||
[]int{0, 0},
|
||||
{0, 0},
|
||||
{1, 1},
|
||||
{0, 0},
|
||||
}},
|
||||
ans63{0},
|
||||
},
|
||||
|
||||
question63{
|
||||
{
|
||||
para63{[][]int{
|
||||
[]int{0, 1, 0, 0},
|
||||
[]int{1, 0, 0, 0},
|
||||
[]int{0, 0, 0, 0},
|
||||
{0, 1, 0, 0},
|
||||
{1, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
}},
|
||||
ans63{0},
|
||||
},
|
||||
|
@ -26,11 +26,11 @@ func Test_Problem64(t *testing.T) {
|
||||
|
||||
qs := []question64{
|
||||
|
||||
question64{
|
||||
{
|
||||
para64{[][]int{
|
||||
[]int{1, 3, 1},
|
||||
[]int{1, 5, 1},
|
||||
[]int{4, 2, 1},
|
||||
{1, 3, 1},
|
||||
{1, 5, 1},
|
||||
{4, 2, 1},
|
||||
}},
|
||||
ans64{7},
|
||||
},
|
||||
|
@ -26,22 +26,22 @@ func Test_Problem66(t *testing.T) {
|
||||
|
||||
qs := []question66{
|
||||
|
||||
question66{
|
||||
{
|
||||
para66{[]int{1, 2, 3}},
|
||||
ans66{[]int{1, 2, 4}},
|
||||
},
|
||||
|
||||
question66{
|
||||
{
|
||||
para66{[]int{4, 3, 2, 1}},
|
||||
ans66{[]int{4, 3, 2, 2}},
|
||||
},
|
||||
|
||||
question66{
|
||||
{
|
||||
para66{[]int{9, 9}},
|
||||
ans66{[]int{1, 0, 0}},
|
||||
},
|
||||
|
||||
question66{
|
||||
{
|
||||
para66{[]int{0}},
|
||||
ans66{[]int{0}},
|
||||
},
|
||||
|
@ -27,12 +27,12 @@ func Test_Problem67(t *testing.T) {
|
||||
|
||||
qs := []question67{
|
||||
|
||||
question67{
|
||||
{
|
||||
para67{"11", "1"},
|
||||
ans67{"100"},
|
||||
},
|
||||
|
||||
question67{
|
||||
{
|
||||
para67{"1010", "1011"},
|
||||
ans67{"10101"},
|
||||
},
|
||||
|
@ -26,12 +26,12 @@ func Test_Problem69(t *testing.T) {
|
||||
|
||||
qs := []question69{
|
||||
|
||||
question69{
|
||||
{
|
||||
para69{4},
|
||||
ans69{2},
|
||||
},
|
||||
|
||||
question69{
|
||||
{
|
||||
para69{8},
|
||||
ans69{2},
|
||||
},
|
||||
|
@ -26,12 +26,12 @@ func Test_Problem70(t *testing.T) {
|
||||
|
||||
qs := []question70{
|
||||
|
||||
question70{
|
||||
{
|
||||
para70{2},
|
||||
ans70{2},
|
||||
},
|
||||
|
||||
question70{
|
||||
{
|
||||
para70{3},
|
||||
ans70{3},
|
||||
},
|
||||
|
@ -26,42 +26,42 @@ func Test_Problem71(t *testing.T) {
|
||||
|
||||
qs := []question71{
|
||||
|
||||
question71{
|
||||
{
|
||||
para71{"/.hidden"},
|
||||
ans71{"/.hidden"},
|
||||
},
|
||||
|
||||
question71{
|
||||
{
|
||||
para71{"/..hidden"},
|
||||
ans71{"/..hidden"},
|
||||
},
|
||||
|
||||
question71{
|
||||
{
|
||||
para71{"/abc/..."},
|
||||
ans71{"/abc/..."},
|
||||
},
|
||||
|
||||
question71{
|
||||
{
|
||||
para71{"/home/"},
|
||||
ans71{"/home"},
|
||||
},
|
||||
|
||||
question71{
|
||||
{
|
||||
para71{"/..."},
|
||||
ans71{"/..."},
|
||||
},
|
||||
|
||||
question71{
|
||||
{
|
||||
para71{"/../"},
|
||||
ans71{"/"},
|
||||
},
|
||||
|
||||
question71{
|
||||
{
|
||||
para71{"/home//foo/"},
|
||||
ans71{"/home/foo"},
|
||||
},
|
||||
|
||||
question71{
|
||||
{
|
||||
para71{"/a/./b/../../c/"},
|
||||
ans71{"/c"},
|
||||
},
|
||||
|
@ -27,13 +27,13 @@ func Test_Problem74(t *testing.T) {
|
||||
|
||||
qs := []question74{
|
||||
|
||||
question74{
|
||||
para74{[][]int{[]int{1, 3, 5, 7}, []int{10, 11, 16, 20}, []int{23, 30, 34, 50}}, 3},
|
||||
{
|
||||
para74{[][]int{{1, 3, 5, 7}, {10, 11, 16, 20}, {23, 30, 34, 50}}, 3},
|
||||
ans74{true},
|
||||
},
|
||||
|
||||
question74{
|
||||
para74{[][]int{[]int{1, 3, 5, 7}, []int{10, 11, 16, 20}, []int{23, 30, 34, 50}}, 13},
|
||||
{
|
||||
para74{[][]int{{1, 3, 5, 7}, {10, 11, 16, 20}, {23, 30, 34, 50}}, 13},
|
||||
ans74{false},
|
||||
},
|
||||
}
|
||||
|
@ -26,22 +26,22 @@ func Test_Problem75(t *testing.T) {
|
||||
|
||||
qs := []question75{
|
||||
|
||||
question75{
|
||||
{
|
||||
para75{[]int{}},
|
||||
ans75{[]int{}},
|
||||
},
|
||||
|
||||
question75{
|
||||
{
|
||||
para75{[]int{1}},
|
||||
ans75{[]int{1}},
|
||||
},
|
||||
|
||||
question75{
|
||||
{
|
||||
para75{[]int{2, 0, 2, 1, 1, 0}},
|
||||
ans75{[]int{0, 0, 1, 1, 2, 2}},
|
||||
},
|
||||
|
||||
question75{
|
||||
{
|
||||
para75{[]int{2, 0, 1, 1, 2, 0, 2, 1, 2, 0, 0, 0, 1, 2, 2, 2, 0, 1, 1}},
|
||||
ans75{[]int{0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2}},
|
||||
},
|
||||
|
@ -27,17 +27,17 @@ func Test_Problem76(t *testing.T) {
|
||||
|
||||
qs := []question76{
|
||||
|
||||
question76{
|
||||
{
|
||||
para76{"ADOBECODEBANC", "ABC"},
|
||||
ans76{"BANC"},
|
||||
},
|
||||
|
||||
question76{
|
||||
{
|
||||
para76{"a", "aa"},
|
||||
ans76{""},
|
||||
},
|
||||
|
||||
question76{
|
||||
{
|
||||
para76{"a", "a"},
|
||||
ans76{"a"},
|
||||
},
|
||||
|
@ -27,9 +27,9 @@ func Test_Problem77(t *testing.T) {
|
||||
|
||||
qs := []question77{
|
||||
|
||||
question77{
|
||||
{
|
||||
para77{4, 2},
|
||||
ans77{[][]int{[]int{2, 4}, []int{3, 4}, []int{2, 3}, []int{1, 2}, []int{1, 3}, []int{1, 4}}},
|
||||
ans77{[][]int{{2, 4}, {3, 4}, {2, 3}, {1, 2}, {1, 3}, {1, 4}}},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -26,14 +26,14 @@ func Test_Problem78(t *testing.T) {
|
||||
|
||||
qs := []question78{
|
||||
|
||||
question78{
|
||||
{
|
||||
para78{[]int{}},
|
||||
ans78{[][]int{[]int{}}},
|
||||
ans78{[][]int{{}}},
|
||||
},
|
||||
|
||||
question78{
|
||||
{
|
||||
para78{[]int{1, 2, 3}},
|
||||
ans78{[][]int{[]int{}, []int{1}, []int{2}, []int{3}, []int{1, 2}, []int{2, 3}, []int{1, 3}, []int{1, 2, 3}}},
|
||||
ans78{[][]int{{}, {1}, {2}, {3}, {1, 2}, {2, 3}, {1, 3}, {1, 2, 3}}},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
package leetcode
|
||||
|
||||
var dir = [][]int{
|
||||
[]int{-1, 0},
|
||||
[]int{0, 1},
|
||||
[]int{1, 0},
|
||||
[]int{0, -1},
|
||||
{-1, 0},
|
||||
{0, 1},
|
||||
{1, 0},
|
||||
{0, -1},
|
||||
}
|
||||
|
||||
func exist(board [][]byte, word string) bool {
|
||||
|
@ -27,69 +27,69 @@ func Test_Problem79(t *testing.T) {
|
||||
|
||||
qs := []question79{
|
||||
|
||||
question79{
|
||||
{
|
||||
para79{[][]byte{
|
||||
[]byte{'A', 'B', 'C', 'E'},
|
||||
[]byte{'S', 'F', 'C', 'S'},
|
||||
[]byte{'A', 'D', 'E', 'E'},
|
||||
{'A', 'B', 'C', 'E'},
|
||||
{'S', 'F', 'C', 'S'},
|
||||
{'A', 'D', 'E', 'E'},
|
||||
}, "ABCCED"},
|
||||
ans79{true},
|
||||
},
|
||||
|
||||
question79{
|
||||
{
|
||||
para79{[][]byte{
|
||||
[]byte{'A', 'B', 'C', 'E'},
|
||||
[]byte{'S', 'F', 'C', 'S'},
|
||||
[]byte{'A', 'D', 'E', 'E'},
|
||||
{'A', 'B', 'C', 'E'},
|
||||
{'S', 'F', 'C', 'S'},
|
||||
{'A', 'D', 'E', 'E'},
|
||||
}, "SEE"},
|
||||
ans79{true},
|
||||
},
|
||||
|
||||
question79{
|
||||
{
|
||||
para79{[][]byte{
|
||||
[]byte{'A', 'B', 'C', 'E'},
|
||||
[]byte{'S', 'F', 'C', 'S'},
|
||||
[]byte{'A', 'D', 'E', 'E'},
|
||||
{'A', 'B', 'C', 'E'},
|
||||
{'S', 'F', 'C', 'S'},
|
||||
{'A', 'D', 'E', 'E'},
|
||||
}, "ABCB"},
|
||||
ans79{false},
|
||||
},
|
||||
|
||||
question79{
|
||||
{
|
||||
para79{[][]byte{
|
||||
[]byte{'o', 'a', 'a', 'n'},
|
||||
[]byte{'e', 't', 'a', 'e'},
|
||||
[]byte{'i', 'h', 'k', 'r'},
|
||||
[]byte{'i', 'f', 'l', 'v'},
|
||||
{'o', 'a', 'a', 'n'},
|
||||
{'e', 't', 'a', 'e'},
|
||||
{'i', 'h', 'k', 'r'},
|
||||
{'i', 'f', 'l', 'v'},
|
||||
}, "oath"},
|
||||
ans79{true},
|
||||
},
|
||||
|
||||
question79{
|
||||
{
|
||||
para79{[][]byte{
|
||||
[]byte{'o', 'a', 'a', 'n'},
|
||||
[]byte{'e', 't', 'a', 'e'},
|
||||
[]byte{'i', 'h', 'k', 'r'},
|
||||
[]byte{'i', 'f', 'l', 'v'},
|
||||
{'o', 'a', 'a', 'n'},
|
||||
{'e', 't', 'a', 'e'},
|
||||
{'i', 'h', 'k', 'r'},
|
||||
{'i', 'f', 'l', 'v'},
|
||||
}, "pea"},
|
||||
ans79{false},
|
||||
},
|
||||
|
||||
question79{
|
||||
{
|
||||
para79{[][]byte{
|
||||
[]byte{'o', 'a', 'a', 'n'},
|
||||
[]byte{'e', 't', 'a', 'e'},
|
||||
[]byte{'i', 'h', 'k', 'r'},
|
||||
[]byte{'i', 'f', 'l', 'v'},
|
||||
{'o', 'a', 'a', 'n'},
|
||||
{'e', 't', 'a', 'e'},
|
||||
{'i', 'h', 'k', 'r'},
|
||||
{'i', 'f', 'l', 'v'},
|
||||
}, "eat"},
|
||||
ans79{true},
|
||||
},
|
||||
|
||||
question79{
|
||||
{
|
||||
para79{[][]byte{
|
||||
[]byte{'o', 'a', 'a', 'n'},
|
||||
[]byte{'e', 't', 'a', 'e'},
|
||||
[]byte{'i', 'h', 'k', 'r'},
|
||||
[]byte{'i', 'f', 'l', 'v'},
|
||||
{'o', 'a', 'a', 'n'},
|
||||
{'e', 't', 'a', 'e'},
|
||||
{'i', 'h', 'k', 'r'},
|
||||
{'i', 'f', 'l', 'v'},
|
||||
}, "rain"},
|
||||
ans79{false},
|
||||
},
|
||||
|
@ -26,32 +26,32 @@ func Test_Problem80(t *testing.T) {
|
||||
|
||||
qs := []question80{
|
||||
|
||||
question80{
|
||||
{
|
||||
para80{[]int{1, 1, 2}},
|
||||
ans80{3},
|
||||
},
|
||||
|
||||
question80{
|
||||
{
|
||||
para80{[]int{0, 0, 1, 1, 1, 1, 2, 3, 4, 4}},
|
||||
ans80{8},
|
||||
},
|
||||
|
||||
question80{
|
||||
{
|
||||
para80{[]int{0, 0, 0, 0, 0}},
|
||||
ans80{2},
|
||||
},
|
||||
|
||||
question80{
|
||||
{
|
||||
para80{[]int{1}},
|
||||
ans80{1},
|
||||
},
|
||||
|
||||
question80{
|
||||
{
|
||||
para80{[]int{0, 0, 1, 1, 1, 1, 2, 3, 3}},
|
||||
ans80{7},
|
||||
},
|
||||
|
||||
question80{
|
||||
{
|
||||
para80{[]int{1, 1, 1, 1, 2, 2, 3}},
|
||||
ans80{5},
|
||||
},
|
||||
|
@ -27,12 +27,12 @@ func Test_Problem81(t *testing.T) {
|
||||
|
||||
qs := []question81{
|
||||
|
||||
question81{
|
||||
{
|
||||
para81{[]int{2, 5, 6, 0, 0, 1, 2}, 0},
|
||||
ans81{true},
|
||||
},
|
||||
|
||||
question81{
|
||||
{
|
||||
para81{[]int{2, 5, 6, 0, 0, 1, 2}, 3},
|
||||
ans81{false},
|
||||
},
|
||||
|
@ -28,47 +28,47 @@ func Test_Problem82(t *testing.T) {
|
||||
|
||||
qs := []question82{
|
||||
|
||||
question82{
|
||||
{
|
||||
para82{[]int{1, 1, 2, 2, 3, 4, 4, 4}},
|
||||
ans82{[]int{3}},
|
||||
},
|
||||
|
||||
question82{
|
||||
{
|
||||
para82{[]int{1, 1, 1, 1, 1, 1}},
|
||||
ans82{[]int{}},
|
||||
},
|
||||
|
||||
question82{
|
||||
{
|
||||
para82{[]int{1, 1, 1, 2, 3}},
|
||||
ans82{[]int{2, 3}},
|
||||
},
|
||||
|
||||
question82{
|
||||
{
|
||||
para82{[]int{1}},
|
||||
ans82{[]int{1}},
|
||||
},
|
||||
|
||||
question82{
|
||||
{
|
||||
para82{[]int{}},
|
||||
ans82{[]int{}},
|
||||
},
|
||||
|
||||
question82{
|
||||
{
|
||||
para82{[]int{1, 2, 2, 2, 2}},
|
||||
ans82{[]int{1}},
|
||||
},
|
||||
|
||||
question82{
|
||||
{
|
||||
para82{[]int{1, 1, 2, 3, 3, 4, 5, 5, 6}},
|
||||
ans82{[]int{2, 4, 6}},
|
||||
},
|
||||
|
||||
question82{
|
||||
{
|
||||
para82{[]int{1, 1, 2, 3, 3, 4, 5, 6}},
|
||||
ans82{[]int{2, 4, 5, 6}},
|
||||
},
|
||||
|
||||
question82{
|
||||
{
|
||||
para82{[]int{0, 1, 2, 2, 3, 4}},
|
||||
ans82{[]int{0, 1, 2, 2, 3, 4}},
|
||||
},
|
||||
|
@ -28,17 +28,17 @@ func Test_Problem83(t *testing.T) {
|
||||
|
||||
qs := []question83{
|
||||
|
||||
question83{
|
||||
{
|
||||
para83{[]int{1, 1, 2}},
|
||||
ans83{[]int{1, 2}},
|
||||
},
|
||||
|
||||
question83{
|
||||
{
|
||||
para83{[]int{1, 1, 2, 2, 3, 3, 3}},
|
||||
ans83{[]int{1, 2, 3}},
|
||||
},
|
||||
|
||||
question83{
|
||||
{
|
||||
para83{[]int{1, 1, 1, 1, 1, 1, 1, 1}},
|
||||
ans83{[]int{1}},
|
||||
},
|
||||
|
@ -26,17 +26,17 @@ func Test_Problem84(t *testing.T) {
|
||||
|
||||
qs := []question84{
|
||||
|
||||
question84{
|
||||
{
|
||||
para84{[]int{2, 1, 5, 6, 2, 3}},
|
||||
ans84{10},
|
||||
},
|
||||
|
||||
question84{
|
||||
{
|
||||
para84{[]int{1}},
|
||||
ans84{1},
|
||||
},
|
||||
|
||||
question84{
|
||||
{
|
||||
para84{[]int{1, 1}},
|
||||
ans84{2},
|
||||
},
|
||||
|
@ -29,37 +29,37 @@ func Test_Problem86(t *testing.T) {
|
||||
|
||||
qs := []question86{
|
||||
|
||||
question86{
|
||||
{
|
||||
para86{[]int{1, 4, 3, 2, 5, 2}, 3},
|
||||
ans86{[]int{1, 2, 2, 4, 3, 5}},
|
||||
},
|
||||
|
||||
question86{
|
||||
{
|
||||
para86{[]int{1, 1, 2, 2, 3, 3, 3}, 2},
|
||||
ans86{[]int{1, 1, 2, 2, 3, 3, 3}},
|
||||
},
|
||||
|
||||
question86{
|
||||
{
|
||||
para86{[]int{1, 4, 3, 2, 5, 2}, 0},
|
||||
ans86{[]int{1, 4, 3, 2, 5, 2}},
|
||||
},
|
||||
|
||||
question86{
|
||||
{
|
||||
para86{[]int{4, 3, 2, 5, 2}, 3},
|
||||
ans86{[]int{2, 2, 4, 3, 5}},
|
||||
},
|
||||
|
||||
question86{
|
||||
{
|
||||
para86{[]int{1, 1, 1, 1, 1, 1}, 1},
|
||||
ans86{[]int{1, 1, 1, 1, 1, 1}},
|
||||
},
|
||||
|
||||
question86{
|
||||
{
|
||||
para86{[]int{3, 1}, 2},
|
||||
ans86{[]int{1, 3}},
|
||||
},
|
||||
|
||||
question86{
|
||||
{
|
||||
para86{[]int{1, 2}, 3},
|
||||
ans86{[]int{1, 2}},
|
||||
},
|
||||
|
@ -44,7 +44,7 @@ func Test_Problem88(t *testing.T) {
|
||||
// ans{[]int{1, 2, 2, 3}},
|
||||
// },
|
||||
|
||||
question88{
|
||||
{
|
||||
para88{[]int{1, 2, 3, 0, 0, 0}, 3, []int{2, 5, 6}, 3},
|
||||
ans88{[]int{1, 2, 2, 3, 5, 6}},
|
||||
},
|
||||
|
@ -26,17 +26,17 @@ func Test_Problem89(t *testing.T) {
|
||||
|
||||
qs := []question89{
|
||||
|
||||
question89{
|
||||
{
|
||||
para89{2},
|
||||
ans89{[]int{0, 1, 3, 2}},
|
||||
},
|
||||
|
||||
question89{
|
||||
{
|
||||
para89{0},
|
||||
ans89{[]int{0}},
|
||||
},
|
||||
|
||||
question89{
|
||||
{
|
||||
para89{3},
|
||||
ans89{[]int{0, 1, 3, 2, 6, 7, 5, 4}},
|
||||
},
|
||||
|
@ -26,14 +26,14 @@ func Test_Problem90(t *testing.T) {
|
||||
|
||||
qs := []question90{
|
||||
|
||||
question90{
|
||||
{
|
||||
para90{[]int{}},
|
||||
ans90{[][]int{[]int{}}},
|
||||
ans90{[][]int{{}}},
|
||||
},
|
||||
|
||||
question90{
|
||||
{
|
||||
para90{[]int{1, 2, 2}},
|
||||
ans90{[][]int{[]int{}, []int{1}, []int{2}, []int{1, 2}, []int{2, 2}, []int{1, 2, 2}}},
|
||||
ans90{[][]int{{}, {1}, {2}, {1, 2}, {2, 2}, {1, 2, 2}}},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -26,12 +26,12 @@ func Test_Problem91(t *testing.T) {
|
||||
|
||||
qs := []question91{
|
||||
|
||||
question91{
|
||||
{
|
||||
para91{"12"},
|
||||
ans91{2},
|
||||
},
|
||||
|
||||
question91{
|
||||
{
|
||||
para91{"226"},
|
||||
ans91{3},
|
||||
},
|
||||
|
@ -29,32 +29,32 @@ func Test_Problem92(t *testing.T) {
|
||||
|
||||
qs := []question92{
|
||||
|
||||
question92{
|
||||
{
|
||||
para92{[]int{1, 2, 3, 4, 5}, 2, 4},
|
||||
ans92{[]int{1, 4, 3, 2, 5}},
|
||||
},
|
||||
|
||||
question92{
|
||||
{
|
||||
para92{[]int{1, 2, 3, 4, 5}, 2, 2},
|
||||
ans92{[]int{1, 2, 3, 4, 5}},
|
||||
},
|
||||
|
||||
question92{
|
||||
{
|
||||
para92{[]int{1, 2, 3, 4, 5}, 1, 5},
|
||||
ans92{[]int{5, 4, 3, 2, 1}},
|
||||
},
|
||||
|
||||
question92{
|
||||
{
|
||||
para92{[]int{1, 2, 3, 4, 5, 6}, 3, 4},
|
||||
ans92{[]int{1, 2, 4, 3, 5, 6}},
|
||||
},
|
||||
|
||||
question92{
|
||||
{
|
||||
para92{[]int{3, 5}, 1, 2},
|
||||
ans92{[]int{5, 3}},
|
||||
},
|
||||
|
||||
question92{
|
||||
{
|
||||
para92{[]int{3}, 3, 5},
|
||||
ans92{[]int{3}},
|
||||
},
|
||||
|
@ -26,17 +26,17 @@ func Test_Problem93(t *testing.T) {
|
||||
|
||||
qs := []question93{
|
||||
|
||||
question93{
|
||||
{
|
||||
para93{"25525511135"},
|
||||
ans93{[]string{"255.255.11.135", "255.255.111.35"}},
|
||||
},
|
||||
|
||||
question93{
|
||||
{
|
||||
para93{"0000"},
|
||||
ans93{[]string{"0.0.0.0"}},
|
||||
},
|
||||
|
||||
question93{
|
||||
{
|
||||
para93{"010010"},
|
||||
ans93{[]string{"0.10.0.10", "0.100.1.0"}},
|
||||
},
|
||||
|
@ -28,17 +28,17 @@ func Test_Problem94(t *testing.T) {
|
||||
|
||||
qs := []question94{
|
||||
|
||||
question94{
|
||||
{
|
||||
para94{[]int{}},
|
||||
ans94{[]int{}},
|
||||
},
|
||||
|
||||
question94{
|
||||
{
|
||||
para94{[]int{1}},
|
||||
ans94{[]int{1}},
|
||||
},
|
||||
|
||||
question94{
|
||||
{
|
||||
para94{[]int{1, structures.NULL, 2, 3}},
|
||||
ans94{[]int{1, 2, 3}},
|
||||
},
|
||||
|
@ -28,19 +28,19 @@ func Test_Problem95(t *testing.T) {
|
||||
|
||||
qs := []question95{
|
||||
|
||||
question95{
|
||||
{
|
||||
para95{1},
|
||||
ans95{[]*TreeNode{&TreeNode{Val: 1, Left: nil, Right: nil}}},
|
||||
ans95{[]*TreeNode{{Val: 1, Left: nil, Right: nil}}},
|
||||
},
|
||||
|
||||
question95{
|
||||
{
|
||||
para95{3},
|
||||
ans95{[]*TreeNode{
|
||||
&TreeNode{Val: 1, Left: nil, Right: &TreeNode{Val: 3, Left: &TreeNode{Val: 2, Left: nil, Right: nil}, Right: nil}},
|
||||
&TreeNode{Val: 1, Left: nil, Right: &TreeNode{Val: 2, Left: nil, Right: &TreeNode{Val: 3, Left: nil, Right: nil}}},
|
||||
&TreeNode{Val: 3, Left: &TreeNode{Val: 2, Left: &TreeNode{Val: 1, Left: nil, Right: nil}, Right: nil}, Right: nil},
|
||||
&TreeNode{Val: 3, Left: &TreeNode{Val: 1, Left: nil, Right: &TreeNode{Val: 2, Left: nil, Right: nil}}, Right: nil},
|
||||
&TreeNode{Val: 2, Left: &TreeNode{Val: 1, Left: nil, Right: nil}, Right: &TreeNode{Val: 3, Left: nil, Right: nil}},
|
||||
{Val: 1, Left: nil, Right: &TreeNode{Val: 3, Left: &TreeNode{Val: 2, Left: nil, Right: nil}, Right: nil}},
|
||||
{Val: 1, Left: nil, Right: &TreeNode{Val: 2, Left: nil, Right: &TreeNode{Val: 3, Left: nil, Right: nil}}},
|
||||
{Val: 3, Left: &TreeNode{Val: 2, Left: &TreeNode{Val: 1, Left: nil, Right: nil}, Right: nil}, Right: nil},
|
||||
{Val: 3, Left: &TreeNode{Val: 1, Left: nil, Right: &TreeNode{Val: 2, Left: nil, Right: nil}}, Right: nil},
|
||||
{Val: 2, Left: &TreeNode{Val: 1, Left: nil, Right: nil}, Right: &TreeNode{Val: 3, Left: nil, Right: nil}},
|
||||
}}},
|
||||
}
|
||||
|
||||
|
@ -26,46 +26,46 @@ func Test_Problem96(t *testing.T) {
|
||||
|
||||
qs := []question96{
|
||||
|
||||
question96{
|
||||
{
|
||||
para96{1},
|
||||
ans96{1},
|
||||
},
|
||||
|
||||
question96{
|
||||
{
|
||||
para96{3},
|
||||
ans96{5},
|
||||
},
|
||||
|
||||
question96{
|
||||
{
|
||||
para96{4},
|
||||
ans96{14},
|
||||
},
|
||||
|
||||
question96{
|
||||
{
|
||||
para96{5},
|
||||
ans96{42},
|
||||
},
|
||||
|
||||
question96{
|
||||
{
|
||||
para96{6},
|
||||
ans96{132},
|
||||
},
|
||||
|
||||
question96{
|
||||
{
|
||||
para96{7},
|
||||
ans96{429},
|
||||
},
|
||||
|
||||
question96{
|
||||
{
|
||||
para96{8},
|
||||
ans96{1430},
|
||||
},
|
||||
|
||||
question96{
|
||||
{
|
||||
para96{9},
|
||||
ans96{4862},
|
||||
},
|
||||
question96{
|
||||
{
|
||||
para96{10},
|
||||
ans96{16796},
|
||||
},
|
||||
|
@ -28,22 +28,22 @@ func Test_Problem98(t *testing.T) {
|
||||
|
||||
qs := []question98{
|
||||
|
||||
question98{
|
||||
{
|
||||
para98{[]int{10, 5, 15, structures.NULL, structures.NULL, 6, 20}},
|
||||
ans98{false},
|
||||
},
|
||||
|
||||
question98{
|
||||
{
|
||||
para98{[]int{}},
|
||||
ans98{true},
|
||||
},
|
||||
|
||||
question98{
|
||||
{
|
||||
para98{[]int{2, 1, 3}},
|
||||
ans98{true},
|
||||
},
|
||||
|
||||
question98{
|
||||
{
|
||||
para98{[]int{5, 1, 4, structures.NULL, structures.NULL, 3, 6}},
|
||||
ans98{false},
|
||||
},
|
||||
|
@ -28,12 +28,12 @@ func Test_Problem99(t *testing.T) {
|
||||
|
||||
qs := []question99{
|
||||
|
||||
question99{
|
||||
{
|
||||
para99{[]int{1, 3, structures.NULL, structures.NULL, 2}},
|
||||
ans99{[]int{3, 1, structures.NULL, structures.NULL, 2}},
|
||||
},
|
||||
|
||||
question99{
|
||||
{
|
||||
para99{[]int{3, 1, 4, structures.NULL, structures.NULL, 2}},
|
||||
ans99{[]int{2, 1, 4, structures.NULL, structures.NULL, 3}},
|
||||
},
|
||||
|
@ -29,32 +29,32 @@ func Test_Problem100(t *testing.T) {
|
||||
|
||||
qs := []question100{
|
||||
|
||||
question100{
|
||||
{
|
||||
para100{[]int{}, []int{}},
|
||||
ans100{true},
|
||||
},
|
||||
|
||||
question100{
|
||||
{
|
||||
para100{[]int{}, []int{1}},
|
||||
ans100{false},
|
||||
},
|
||||
|
||||
question100{
|
||||
{
|
||||
para100{[]int{1}, []int{1}},
|
||||
ans100{true},
|
||||
},
|
||||
|
||||
question100{
|
||||
{
|
||||
para100{[]int{1, 2, 3}, []int{1, 2, 3}},
|
||||
ans100{true},
|
||||
},
|
||||
|
||||
question100{
|
||||
{
|
||||
para100{[]int{1, 2}, []int{1, structures.NULL, 2}},
|
||||
ans100{false},
|
||||
},
|
||||
|
||||
question100{
|
||||
{
|
||||
para100{[]int{1, 2, 1}, []int{1, 1, 2}},
|
||||
ans100{false},
|
||||
},
|
||||
|
@ -28,37 +28,37 @@ func Test_Problem101(t *testing.T) {
|
||||
|
||||
qs := []question101{
|
||||
|
||||
question101{
|
||||
{
|
||||
para101{[]int{3, 4, 4, 5, structures.NULL, structures.NULL, 5, 6, structures.NULL, structures.NULL, 6}},
|
||||
ans101{true},
|
||||
},
|
||||
|
||||
question101{
|
||||
{
|
||||
para101{[]int{1, 2, 2, structures.NULL, 3, 3}},
|
||||
ans101{true},
|
||||
},
|
||||
|
||||
question101{
|
||||
{
|
||||
para101{[]int{}},
|
||||
ans101{true},
|
||||
},
|
||||
|
||||
question101{
|
||||
{
|
||||
para101{[]int{1}},
|
||||
ans101{true},
|
||||
},
|
||||
|
||||
question101{
|
||||
{
|
||||
para101{[]int{1, 2, 3}},
|
||||
ans101{false},
|
||||
},
|
||||
|
||||
question101{
|
||||
{
|
||||
para101{[]int{1, 2, 2, 3, 4, 4, 3}},
|
||||
ans101{true},
|
||||
},
|
||||
|
||||
question101{
|
||||
{
|
||||
para101{[]int{1, 2, 2, structures.NULL, 3, structures.NULL, 3}},
|
||||
ans101{false},
|
||||
},
|
||||
|
@ -28,19 +28,19 @@ func Test_Problem102(t *testing.T) {
|
||||
|
||||
qs := []question102{
|
||||
|
||||
question102{
|
||||
{
|
||||
para102{[]int{}},
|
||||
ans102{[][]int{}},
|
||||
},
|
||||
|
||||
question102{
|
||||
{
|
||||
para102{[]int{1}},
|
||||
ans102{[][]int{[]int{1}}},
|
||||
ans102{[][]int{{1}}},
|
||||
},
|
||||
|
||||
question102{
|
||||
{
|
||||
para102{[]int{3, 9, 20, structures.NULL, structures.NULL, 15, 7}},
|
||||
ans102{[][]int{[]int{3}, []int{9, 20}, []int{15, 7}}},
|
||||
ans102{[][]int{{3}, {9, 20}, {15, 7}}},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -28,24 +28,24 @@ func Test_Problem103(t *testing.T) {
|
||||
|
||||
qs := []question103{
|
||||
|
||||
question103{
|
||||
{
|
||||
para103{[]int{}},
|
||||
ans103{[][]int{}},
|
||||
},
|
||||
|
||||
question103{
|
||||
{
|
||||
para103{[]int{1}},
|
||||
ans103{[][]int{[]int{1}}},
|
||||
ans103{[][]int{{1}}},
|
||||
},
|
||||
|
||||
question103{
|
||||
{
|
||||
para103{[]int{3, 9, 20, structures.NULL, structures.NULL, 15, 7}},
|
||||
ans103{[][]int{[]int{3}, []int{9, 20}, []int{15, 7}}},
|
||||
ans103{[][]int{{3}, {9, 20}, {15, 7}}},
|
||||
},
|
||||
|
||||
question103{
|
||||
{
|
||||
para103{[]int{1, 2, 3, 4, structures.NULL, structures.NULL, 5}},
|
||||
ans103{[][]int{[]int{1}, []int{3, 2}, []int{4, 5}}},
|
||||
ans103{[][]int{{1}, {3, 2}, {4, 5}}},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -28,12 +28,12 @@ func Test_Problem104(t *testing.T) {
|
||||
|
||||
qs := []question104{
|
||||
|
||||
question104{
|
||||
{
|
||||
para104{[]int{}},
|
||||
ans104{0},
|
||||
},
|
||||
|
||||
question104{
|
||||
{
|
||||
para104{[]int{3, 9, 20, structures.NULL, structures.NULL, 15, 7}},
|
||||
ans104{3},
|
||||
},
|
||||
|
@ -29,7 +29,7 @@ func Test_Problem105(t *testing.T) {
|
||||
|
||||
qs := []question105{
|
||||
|
||||
question105{
|
||||
{
|
||||
para105{[]int{3, 9, 20, 15, 7}, []int{9, 3, 15, 20, 7}},
|
||||
ans105{[]int{3, 9, 20, structures.NULL, structures.NULL, 15, 7}},
|
||||
},
|
||||
|
@ -29,7 +29,7 @@ func Test_Problem106(t *testing.T) {
|
||||
|
||||
qs := []question106{
|
||||
|
||||
question106{
|
||||
{
|
||||
para106{[]int{9, 3, 15, 20, 7}, []int{9, 15, 7, 20, 3}},
|
||||
ans106{[]int{3, 9, 20, structures.NULL, structures.NULL, 15, 7}},
|
||||
},
|
||||
|
@ -28,19 +28,19 @@ func Test_Problem107(t *testing.T) {
|
||||
|
||||
qs := []question107{
|
||||
|
||||
question107{
|
||||
{
|
||||
para107{[]int{}},
|
||||
ans107{[][]int{}},
|
||||
},
|
||||
|
||||
question107{
|
||||
{
|
||||
para107{[]int{1}},
|
||||
ans107{[][]int{[]int{1}}},
|
||||
ans107{[][]int{{1}}},
|
||||
},
|
||||
|
||||
question107{
|
||||
{
|
||||
para107{[]int{3, 9, 20, structures.NULL, structures.NULL, 15, 7}},
|
||||
ans107{[][]int{[]int{15, 7}, []int{9, 20}, []int{3}}},
|
||||
ans107{[][]int{{15, 7}, {9, 20}, {3}}},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ func Test_Problem108(t *testing.T) {
|
||||
|
||||
qs := []question108{
|
||||
|
||||
question108{
|
||||
{
|
||||
para108{[]int{-10, -3, 0, 5, 9}},
|
||||
ans108{[]int{0, -3, 9, -10, structures.NULL, 5}},
|
||||
},
|
||||
|
@ -28,22 +28,22 @@ func Test_Problem109(t *testing.T) {
|
||||
|
||||
qs := []question109{
|
||||
|
||||
question109{
|
||||
{
|
||||
para109{[]int{-10, -3, 0, 5, 9}},
|
||||
ans109{[]int{0, -10, 5, structures.NULL, -3, structures.NULL, 9}},
|
||||
},
|
||||
|
||||
question109{
|
||||
{
|
||||
para109{[]int{-10}},
|
||||
ans109{[]int{-10}},
|
||||
},
|
||||
|
||||
question109{
|
||||
{
|
||||
para109{[]int{1, 2}},
|
||||
ans109{[]int{1, 2}},
|
||||
},
|
||||
|
||||
question109{
|
||||
{
|
||||
para109{[]int{1, 2, 3}},
|
||||
ans109{[]int{2, 1, 3}},
|
||||
},
|
||||
|
@ -28,37 +28,37 @@ func Test_Problem110(t *testing.T) {
|
||||
|
||||
qs := []question110{
|
||||
|
||||
question110{
|
||||
{
|
||||
para110{[]int{3, 4, 4, 5, structures.NULL, structures.NULL, 5, 6, structures.NULL, structures.NULL, 6}},
|
||||
ans110{false},
|
||||
},
|
||||
|
||||
question110{
|
||||
{
|
||||
para110{[]int{1, 2, 2, structures.NULL, 3, 3}},
|
||||
ans110{true},
|
||||
},
|
||||
|
||||
question110{
|
||||
{
|
||||
para110{[]int{}},
|
||||
ans110{true},
|
||||
},
|
||||
|
||||
question110{
|
||||
{
|
||||
para110{[]int{1}},
|
||||
ans110{true},
|
||||
},
|
||||
|
||||
question110{
|
||||
{
|
||||
para110{[]int{1, 2, 3}},
|
||||
ans110{true},
|
||||
},
|
||||
|
||||
question110{
|
||||
{
|
||||
para110{[]int{1, 2, 2, 3, 4, 4, 3}},
|
||||
ans110{true},
|
||||
},
|
||||
|
||||
question110{
|
||||
{
|
||||
para110{[]int{1, 2, 2, structures.NULL, 3, structures.NULL, 3}},
|
||||
ans110{true},
|
||||
},
|
||||
|
@ -28,22 +28,22 @@ func Test_Problem111(t *testing.T) {
|
||||
|
||||
qs := []question111{
|
||||
|
||||
question111{
|
||||
{
|
||||
para111{[]int{}},
|
||||
ans111{0},
|
||||
},
|
||||
|
||||
question111{
|
||||
{
|
||||
para111{[]int{1}},
|
||||
ans111{1},
|
||||
},
|
||||
|
||||
question111{
|
||||
{
|
||||
para111{[]int{3, 9, 20, structures.NULL, structures.NULL, 15, 7}},
|
||||
ans111{2},
|
||||
},
|
||||
|
||||
question111{
|
||||
{
|
||||
para111{[]int{1, 2}},
|
||||
ans111{2},
|
||||
},
|
||||
|
@ -29,12 +29,12 @@ func Test_Problem112(t *testing.T) {
|
||||
|
||||
qs := []question112{
|
||||
|
||||
question112{
|
||||
{
|
||||
para112{[]int{}, 0},
|
||||
ans112{false},
|
||||
},
|
||||
|
||||
question112{
|
||||
{
|
||||
para112{[]int{5, 4, 8, 11, structures.NULL, 13, 4, 7, 2, structures.NULL, structures.NULL, structures.NULL, 1}, 22},
|
||||
ans112{true},
|
||||
},
|
||||
|
@ -45,7 +45,7 @@ func pathSum1(root *TreeNode, sum int) [][]int {
|
||||
}
|
||||
if root.Left == nil && root.Right == nil {
|
||||
if sum == root.Val {
|
||||
return [][]int{[]int{root.Val}}
|
||||
return [][]int{{root.Val}}
|
||||
}
|
||||
}
|
||||
path, res := []int{}, [][]int{}
|
||||
|
@ -28,19 +28,19 @@ type ans113 struct {
|
||||
func Test_Problem113(t *testing.T) {
|
||||
|
||||
qs := []question113{
|
||||
question113{
|
||||
{
|
||||
para113{[]int{1, 0, 1, 1, 2, 0, -1, 0, 1, -1, 0, -1, 0, 1, 0}, 2},
|
||||
ans113{[][]int{[]int{1, 0, 1, 0}, []int{1, 0, 2, -1}, []int{1, 1, 0, 0}, []int{1, 1, -1, 1}}},
|
||||
ans113{[][]int{{1, 0, 1, 0}, {1, 0, 2, -1}, {1, 1, 0, 0}, {1, 1, -1, 1}}},
|
||||
},
|
||||
|
||||
question113{
|
||||
{
|
||||
para113{[]int{}, 0},
|
||||
ans113{[][]int{[]int{}}},
|
||||
ans113{[][]int{{}}},
|
||||
},
|
||||
|
||||
question113{
|
||||
{
|
||||
para113{[]int{5, 4, 8, 11, structures.NULL, 13, 4, 7, 2, structures.NULL, structures.NULL, 5, 1}, 22},
|
||||
ans113{[][]int{[]int{5, 4, 11, 2}, []int{5, 8, 4, 5}}},
|
||||
ans113{[][]int{{5, 4, 11, 2}, {5, 8, 4, 5}}},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ func Test_Problem114(t *testing.T) {
|
||||
|
||||
qs := []question114{
|
||||
|
||||
question114{
|
||||
{
|
||||
para114{[]int{1, 2, 3, 4, 5, 6}},
|
||||
ans114{[]int{1, 2, 3, 4, 5, 6}},
|
||||
},
|
||||
|
@ -26,17 +26,17 @@ func Test_Problem118(t *testing.T) {
|
||||
|
||||
qs := []question118{
|
||||
|
||||
question118{
|
||||
{
|
||||
para118{2},
|
||||
ans118{[][]int{{1}, {1, 1}}},
|
||||
},
|
||||
|
||||
question118{
|
||||
{
|
||||
para118{5},
|
||||
ans118{[][]int{{1}, {1, 1}, {1, 2, 1}, {1, 3, 3, 1}, {1, 4, 6, 4, 1}}},
|
||||
},
|
||||
|
||||
question118{
|
||||
{
|
||||
para118{10},
|
||||
ans118{[][]int{{1}, {1, 1}, {1, 2, 1}, {1, 3, 3, 1}, {1, 4, 6, 4, 1}, {1, 5, 10, 10, 5, 1}, {1, 6, 15, 20, 15, 6, 1}, {1, 7, 21, 35, 35, 21, 7, 1}, {1, 8, 28, 56, 70, 56, 28, 8, 1}, {1, 9, 36, 84, 126, 126, 84, 36, 9, 1}}},
|
||||
},
|
||||
|
@ -25,8 +25,8 @@ type ans120 struct {
|
||||
func Test_Problem120(t *testing.T) {
|
||||
|
||||
qs := []question120{
|
||||
question120{
|
||||
para120{[][]int{[]int{2}, []int{3, 4}, []int{6, 5, 7}, []int{4, 1, 8, 3}}},
|
||||
{
|
||||
para120{[][]int{{2}, {3, 4}, {6, 5, 7}, {4, 1, 8, 3}}},
|
||||
ans120{11},
|
||||
},
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user