From 19139fec4474b66e36e60248b3440495b53f9694 Mon Sep 17 00:00:00 2001 From: openset Date: Wed, 13 Nov 2019 10:44:52 +0800 Subject: [PATCH] Update: not use dot imports --- problems/add-one-row-to-tree/add_one_row_to_tree.go | 1 + problems/add-two-numbers-ii/add_two_numbers_ii.go | 1 + problems/add-two-numbers/add_two_numbers.go | 1 + .../balanced-binary-tree/balanced_binary_tree.go | 1 + .../construct_string_from_binary_tree.go | 5 ++++- .../construct_string_from_binary_tree_test.go | 6 +++--- .../convert_sorted_array_to_binary_search_tree.go | 1 + .../cousins-in-binary-tree/cousins_in_binary_tree.go | 5 ++++- .../cousins_in_binary_tree_test.go | 12 ++++++------ .../delete_node_in_a_linked_list.go | 5 ++++- .../delete_node_in_a_linked_list_test.go | 6 +++--- .../intersection_of_two_arrays_ii_test.go | 4 ++-- .../intersection_of_two_linked_lists.go | 5 ++++- .../intersection_of_two_linked_lists_test.go | 8 ++++---- problems/linked-list-cycle/linked_list_cycle.go | 5 ++++- problems/linked-list-cycle/linked_list_cycle_test.go | 4 ++-- .../maximum_depth_of_binary_tree.go | 5 ++++- .../maximum_depth_of_binary_tree_test.go | 12 ++++++------ .../median_of_two_sorted_arrays.go | 5 ++--- .../merge-two-binary-trees/merge_two_binary_trees.go | 5 ++++- .../merge_two_binary_trees_test.go | 10 +++++----- .../merge-two-sorted-lists/merge_two_sorted_lists.go | 5 ++++- .../merge_two_sorted_lists_test.go | 8 ++++---- .../palindrome-linked-list/palindrome_linked_list.go | 5 ++++- .../palindrome_linked_list_test.go | 4 ++-- problems/powerful-integers/powerful_integers_test.go | 4 ++-- problems/range-sum-of-bst/range_sum_of_bst.go | 5 ++++- problems/range-sum-of-bst/range_sum_of_bst_test.go | 8 ++++---- .../remove_duplicates_from_sorted_list.go | 5 ++++- .../remove_duplicates_from_sorted_list_test.go | 6 +++--- problems/reverse-linked-list/reverse_linked_list.go | 5 ++++- .../reverse-linked-list/reverse_linked_list_test.go | 4 ++-- problems/same-tree/same_tree.go | 5 ++++- problems/same-tree/same_tree_test.go | 6 +++--- .../sum_of_root_to_leaf_binary_numbers.go | 5 ++++- .../sum_of_root_to_leaf_binary_numbers_test.go | 6 +++--- problems/symmetric-tree/symmetric_tree.go | 5 ++++- problems/symmetric-tree/symmetric_tree_test.go | 6 +++--- .../univalued-binary-tree/univalued_binary_tree.go | 5 ++++- .../univalued_binary_tree_test.go | 6 +++--- 40 files changed, 131 insertions(+), 79 deletions(-) diff --git a/problems/add-one-row-to-tree/add_one_row_to_tree.go b/problems/add-one-row-to-tree/add_one_row_to_tree.go index efc9d8dd1..fc21be51b 100644 --- a/problems/add-one-row-to-tree/add_one_row_to_tree.go +++ b/problems/add-one-row-to-tree/add_one_row_to_tree.go @@ -2,6 +2,7 @@ package problem623 import "github.com/openset/leetcode/internal/kit" +// TreeNode - Definition for a binary tree node. type TreeNode = kit.TreeNode /** diff --git a/problems/add-two-numbers-ii/add_two_numbers_ii.go b/problems/add-two-numbers-ii/add_two_numbers_ii.go index 4f0114460..c38bcae14 100644 --- a/problems/add-two-numbers-ii/add_two_numbers_ii.go +++ b/problems/add-two-numbers-ii/add_two_numbers_ii.go @@ -2,6 +2,7 @@ package problem445 import "github.com/openset/leetcode/internal/kit" +// ListNode - Definition for singly-linked list. type ListNode = kit.ListNode /** diff --git a/problems/add-two-numbers/add_two_numbers.go b/problems/add-two-numbers/add_two_numbers.go index ec3fb8c1d..77909af8d 100644 --- a/problems/add-two-numbers/add_two_numbers.go +++ b/problems/add-two-numbers/add_two_numbers.go @@ -2,6 +2,7 @@ package problem2 import "github.com/openset/leetcode/internal/kit" +// ListNode - Definition for singly-linked list. type ListNode = kit.ListNode /** diff --git a/problems/balanced-binary-tree/balanced_binary_tree.go b/problems/balanced-binary-tree/balanced_binary_tree.go index abe5c8ea0..ed9f4bfc4 100644 --- a/problems/balanced-binary-tree/balanced_binary_tree.go +++ b/problems/balanced-binary-tree/balanced_binary_tree.go @@ -2,6 +2,7 @@ package problem110 import "github.com/openset/leetcode/internal/kit" +// TreeNode - Definition for a binary tree node. type TreeNode = kit.TreeNode /** diff --git a/problems/construct-string-from-binary-tree/construct_string_from_binary_tree.go b/problems/construct-string-from-binary-tree/construct_string_from_binary_tree.go index 0146f257f..690042882 100644 --- a/problems/construct-string-from-binary-tree/construct_string_from_binary_tree.go +++ b/problems/construct-string-from-binary-tree/construct_string_from_binary_tree.go @@ -3,9 +3,12 @@ package problem606 import ( "strconv" - . "github.com/openset/leetcode/internal/kit" + "github.com/openset/leetcode/internal/kit" ) +// TreeNode - Definition for a binary tree node. +type TreeNode = kit.TreeNode + /** * Definition for a binary tree node. * type TreeNode struct { diff --git a/problems/construct-string-from-binary-tree/construct_string_from_binary_tree_test.go b/problems/construct-string-from-binary-tree/construct_string_from_binary_tree_test.go index 87c5e57e3..2412e5372 100644 --- a/problems/construct-string-from-binary-tree/construct_string_from_binary_tree_test.go +++ b/problems/construct-string-from-binary-tree/construct_string_from_binary_tree_test.go @@ -3,7 +3,7 @@ package problem606 import ( "testing" - . "github.com/openset/leetcode/internal/kit" + "github.com/openset/leetcode/internal/kit" ) type caseType struct { @@ -18,12 +18,12 @@ func TestTree2str(t *testing.T) { expected: "1(2(4))(3)", }, { - input: []int{1, 2, 3, NULL, 4}, + input: []int{1, 2, 3, kit.NULL, 4}, expected: "1(2()(4))(3)", }, } for _, tc := range tests { - output := tree2str(SliceInt2TreeNode(tc.input)) + output := tree2str(kit.SliceInt2TreeNode(tc.input)) if output != tc.expected { t.Fatalf("input: %v, output: %v, expected: %v", tc.input, output, tc.expected) } diff --git a/problems/convert-sorted-array-to-binary-search-tree/convert_sorted_array_to_binary_search_tree.go b/problems/convert-sorted-array-to-binary-search-tree/convert_sorted_array_to_binary_search_tree.go index b7af74baa..a1b41e487 100644 --- a/problems/convert-sorted-array-to-binary-search-tree/convert_sorted_array_to_binary_search_tree.go +++ b/problems/convert-sorted-array-to-binary-search-tree/convert_sorted_array_to_binary_search_tree.go @@ -2,6 +2,7 @@ package problem108 import "github.com/openset/leetcode/internal/kit" +// TreeNode - Definition for a binary tree node. type TreeNode = kit.TreeNode /** diff --git a/problems/cousins-in-binary-tree/cousins_in_binary_tree.go b/problems/cousins-in-binary-tree/cousins_in_binary_tree.go index 4c1b51f92..b2ca1a3f7 100644 --- a/problems/cousins-in-binary-tree/cousins_in_binary_tree.go +++ b/problems/cousins-in-binary-tree/cousins_in_binary_tree.go @@ -1,6 +1,9 @@ package problem993 -import . "github.com/openset/leetcode/internal/kit" +import "github.com/openset/leetcode/internal/kit" + +// TreeNode - Definition for a binary tree node. +type TreeNode = kit.TreeNode /** * Definition for a binary tree node. diff --git a/problems/cousins-in-binary-tree/cousins_in_binary_tree_test.go b/problems/cousins-in-binary-tree/cousins_in_binary_tree_test.go index 2b67c3473..b22d9e0be 100644 --- a/problems/cousins-in-binary-tree/cousins_in_binary_tree_test.go +++ b/problems/cousins-in-binary-tree/cousins_in_binary_tree_test.go @@ -3,7 +3,7 @@ package problem993 import ( "testing" - . "github.com/openset/leetcode/internal/kit" + "github.com/openset/leetcode/internal/kit" ) type caseType struct { @@ -22,32 +22,32 @@ func TestIsCousins(t *testing.T) { expected: false, }, { - input: []int{1, 2, 3, NULL, 4, NULL, 5}, + input: []int{1, 2, 3, kit.NULL, 4, kit.NULL, 5}, x: 5, y: 4, expected: true, }, { - input: []int{1, 2, 3, NULL, 4}, + input: []int{1, 2, 3, kit.NULL, 4}, x: 2, y: 3, expected: false, }, { - input: []int{1, 2, 3, NULL, 4, 5}, + input: []int{1, 2, 3, kit.NULL, 4, 5}, x: 4, y: 5, expected: true, }, { - input: []int{1, 2, 3, NULL, 4, 5}, + input: []int{1, 2, 3, kit.NULL, 4, 5}, x: 5, y: 4, expected: true, }, } for _, tc := range tests { - output := isCousins(SliceInt2TreeNode(tc.input), tc.x, tc.y) + output := isCousins(kit.SliceInt2TreeNode(tc.input), tc.x, tc.y) if output != tc.expected { t.Fatalf("input: %v, output: %v, expected: %v", tc.input, output, tc.expected) } diff --git a/problems/delete-node-in-a-linked-list/delete_node_in_a_linked_list.go b/problems/delete-node-in-a-linked-list/delete_node_in_a_linked_list.go index f6a7e881e..baf0a4d08 100644 --- a/problems/delete-node-in-a-linked-list/delete_node_in_a_linked_list.go +++ b/problems/delete-node-in-a-linked-list/delete_node_in_a_linked_list.go @@ -1,6 +1,9 @@ package problem237 -import . "github.com/openset/leetcode/internal/kit" +import "github.com/openset/leetcode/internal/kit" + +// ListNode - Definition for singly-linked list. +type ListNode = kit.ListNode /** * Definition for singly-linked list. diff --git a/problems/delete-node-in-a-linked-list/delete_node_in_a_linked_list_test.go b/problems/delete-node-in-a-linked-list/delete_node_in_a_linked_list_test.go index 0a4d70525..204271be9 100644 --- a/problems/delete-node-in-a-linked-list/delete_node_in_a_linked_list_test.go +++ b/problems/delete-node-in-a-linked-list/delete_node_in_a_linked_list_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - . "github.com/openset/leetcode/internal/kit" + "github.com/openset/leetcode/internal/kit" ) type caseType struct { @@ -42,13 +42,13 @@ func TestDeleteNode(t *testing.T) { }, } for _, tc := range tests { - head := SliceInt2ListNode(tc.input) + head := kit.SliceInt2ListNode(tc.input) node := head for node != nil && node.Val != tc.node { node = node.Next } deleteNode(node) - output := ListNode2SliceInt(head) + output := kit.ListNode2SliceInt(head) if !reflect.DeepEqual(output, tc.expected) { t.Fatalf("input: %v, output: %v, expected: %v", tc.input, output, tc.expected) } diff --git a/problems/intersection-of-two-arrays-ii/intersection_of_two_arrays_ii_test.go b/problems/intersection-of-two-arrays-ii/intersection_of_two_arrays_ii_test.go index 3cf3cab9a..b9126856d 100644 --- a/problems/intersection-of-two-arrays-ii/intersection_of_two_arrays_ii_test.go +++ b/problems/intersection-of-two-arrays-ii/intersection_of_two_arrays_ii_test.go @@ -3,7 +3,7 @@ package problem350 import ( "testing" - . "github.com/openset/leetcode/internal/kit" + "github.com/openset/leetcode/internal/kit" ) type caseType struct { @@ -32,7 +32,7 @@ func TestIntersect(t *testing.T) { } for _, tc := range tests { output := intersect(tc.nums1, tc.nums2) - if !IsEqualSliceInt(output, tc.expected) { + if !kit.IsEqualSliceInt(output, tc.expected) { t.Fatalf("input: %v %v, output: %v, expected: %v", tc.nums1, tc.nums2, output, tc.expected) } } diff --git a/problems/intersection-of-two-linked-lists/intersection_of_two_linked_lists.go b/problems/intersection-of-two-linked-lists/intersection_of_two_linked_lists.go index b8a29b4ed..2d4fb87db 100644 --- a/problems/intersection-of-two-linked-lists/intersection_of_two_linked_lists.go +++ b/problems/intersection-of-two-linked-lists/intersection_of_two_linked_lists.go @@ -1,6 +1,9 @@ package problem160 -import . "github.com/openset/leetcode/internal/kit" +import "github.com/openset/leetcode/internal/kit" + +// ListNode - Definition for singly-linked list. +type ListNode = kit.ListNode /** * Definition for singly-linked list. diff --git a/problems/intersection-of-two-linked-lists/intersection_of_two_linked_lists_test.go b/problems/intersection-of-two-linked-lists/intersection_of_two_linked_lists_test.go index 4b9216be7..2889d0aa6 100644 --- a/problems/intersection-of-two-linked-lists/intersection_of_two_linked_lists_test.go +++ b/problems/intersection-of-two-linked-lists/intersection_of_two_linked_lists_test.go @@ -3,7 +3,7 @@ package problem160 import ( "testing" - . "github.com/openset/leetcode/internal/kit" + "github.com/openset/leetcode/internal/kit" ) type caseType struct { @@ -36,9 +36,9 @@ func TestGetIntersectionNode(t *testing.T) { }, } for _, tc := range tests { - intersection := SliceInt2ListNode(tc.intersection) - headA := SliceInt2ListNode(tc.headA) - headB := SliceInt2ListNode(tc.headB) + intersection := kit.SliceInt2ListNode(tc.intersection) + headA := kit.SliceInt2ListNode(tc.headA) + headB := kit.SliceInt2ListNode(tc.headB) for n := headA; n != nil; n = n.Next { if n.Next == nil { n.Next = intersection diff --git a/problems/linked-list-cycle/linked_list_cycle.go b/problems/linked-list-cycle/linked_list_cycle.go index 440083a54..883c6928b 100644 --- a/problems/linked-list-cycle/linked_list_cycle.go +++ b/problems/linked-list-cycle/linked_list_cycle.go @@ -1,6 +1,9 @@ package problem141 -import . "github.com/openset/leetcode/internal/kit" +import "github.com/openset/leetcode/internal/kit" + +// ListNode - Definition for singly-linked list. +type ListNode = kit.ListNode /** * Definition for singly-linked list. diff --git a/problems/linked-list-cycle/linked_list_cycle_test.go b/problems/linked-list-cycle/linked_list_cycle_test.go index 06a789747..56e2e6630 100644 --- a/problems/linked-list-cycle/linked_list_cycle_test.go +++ b/problems/linked-list-cycle/linked_list_cycle_test.go @@ -3,7 +3,7 @@ package problem141 import ( "testing" - . "github.com/openset/leetcode/internal/kit" + "github.com/openset/leetcode/internal/kit" ) type caseType struct { @@ -36,7 +36,7 @@ func TestHasCycle(t *testing.T) { }, } for _, tc := range tests { - input := SliceInt2ListNode(tc.input) + input := kit.SliceInt2ListNode(tc.input) p, curr := input, input for i := 0; curr != nil && tc.pos >= 0; i, curr = i+1, curr.Next { if i == tc.pos { diff --git a/problems/maximum-depth-of-binary-tree/maximum_depth_of_binary_tree.go b/problems/maximum-depth-of-binary-tree/maximum_depth_of_binary_tree.go index 8e0c32120..93d3f9c91 100644 --- a/problems/maximum-depth-of-binary-tree/maximum_depth_of_binary_tree.go +++ b/problems/maximum-depth-of-binary-tree/maximum_depth_of_binary_tree.go @@ -1,6 +1,9 @@ package problem104 -import . "github.com/openset/leetcode/internal/kit" +import "github.com/openset/leetcode/internal/kit" + +// TreeNode - Definition for a binary tree node. +type TreeNode = kit.TreeNode /** * Definition for a binary tree node. diff --git a/problems/maximum-depth-of-binary-tree/maximum_depth_of_binary_tree_test.go b/problems/maximum-depth-of-binary-tree/maximum_depth_of_binary_tree_test.go index f4cf839c5..da2787c5c 100644 --- a/problems/maximum-depth-of-binary-tree/maximum_depth_of_binary_tree_test.go +++ b/problems/maximum-depth-of-binary-tree/maximum_depth_of_binary_tree_test.go @@ -3,7 +3,7 @@ package problem104 import ( "testing" - . "github.com/openset/leetcode/internal/kit" + "github.com/openset/leetcode/internal/kit" ) type caseType struct { @@ -14,24 +14,24 @@ type caseType struct { func TestMaxDepth(t *testing.T) { tests := [...]caseType{ { - input: []int{3, 9, 20, NULL, NULL, 15, 7}, + input: []int{3, 9, 20, kit.NULL, kit.NULL, 15, 7}, expected: 3, }, { - input: []int{1, 2, 3, NULL, 5, 6}, + input: []int{1, 2, 3, kit.NULL, 5, 6}, expected: 3, }, { - input: []int{1, 2, NULL, NULL, 5}, + input: []int{1, 2, kit.NULL, kit.NULL, 5}, expected: 3, }, { - input: []int{1, NULL, 3, NULL, 5}, + input: []int{1, kit.NULL, 3, kit.NULL, 5}, expected: 3, }, } for _, tc := range tests { - output := maxDepth(SliceInt2TreeNode(tc.input)) + output := maxDepth(kit.SliceInt2TreeNode(tc.input)) if output != tc.expected { t.Fatalf("input: %v, output: %v, expected: %v", tc.input, output, tc.expected) } diff --git a/problems/median-of-two-sorted-arrays/median_of_two_sorted_arrays.go b/problems/median-of-two-sorted-arrays/median_of_two_sorted_arrays.go index 763527457..352e510c5 100644 --- a/problems/median-of-two-sorted-arrays/median_of_two_sorted_arrays.go +++ b/problems/median-of-two-sorted-arrays/median_of_two_sorted_arrays.go @@ -24,8 +24,7 @@ func findMedianSortedArrays(nums1 []int, nums2 []int) float64 { if count&1 == 1 { k := (count - 1) / 2 return float64(s[k]) - } else { - k := count / 2 - return (float64(s[k-1]) + float64(s[k])) / 2 } + k := count / 2 + return (float64(s[k-1]) + float64(s[k])) / 2 } diff --git a/problems/merge-two-binary-trees/merge_two_binary_trees.go b/problems/merge-two-binary-trees/merge_two_binary_trees.go index a70121a22..0d74d4582 100644 --- a/problems/merge-two-binary-trees/merge_two_binary_trees.go +++ b/problems/merge-two-binary-trees/merge_two_binary_trees.go @@ -1,6 +1,9 @@ package problem617 -import . "github.com/openset/leetcode/internal/kit" +import "github.com/openset/leetcode/internal/kit" + +// TreeNode - Definition for a binary tree node. +type TreeNode = kit.TreeNode /** * Definition for a binary tree node. diff --git a/problems/merge-two-binary-trees/merge_two_binary_trees_test.go b/problems/merge-two-binary-trees/merge_two_binary_trees_test.go index 14b16d7d5..8f7287886 100644 --- a/problems/merge-two-binary-trees/merge_two_binary_trees_test.go +++ b/problems/merge-two-binary-trees/merge_two_binary_trees_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - . "github.com/openset/leetcode/internal/kit" + "github.com/openset/leetcode/internal/kit" ) type caseType struct { @@ -17,13 +17,13 @@ func TestMergeTrees(t *testing.T) { tests := [...]caseType{ { t1: []int{1, 3, 2, 5}, - t2: []int{2, 1, 3, NULL, 4, NULL, 7}, - expected: []int{3, 4, 5, 5, 4, NULL, 7}, + t2: []int{2, 1, 3, kit.NULL, 4, kit.NULL, 7}, + expected: []int{3, 4, 5, 5, 4, kit.NULL, 7}, }, } for _, tc := range tests { - t3 := mergeTrees(SliceInt2TreeNode(tc.t1), SliceInt2TreeNode(tc.t2)) - output := TreeNode2SliceInt(t3) + t3 := mergeTrees(kit.SliceInt2TreeNode(tc.t1), kit.SliceInt2TreeNode(tc.t2)) + output := kit.TreeNode2SliceInt(t3) if !reflect.DeepEqual(output, tc.expected) { t.Fatalf("input: %v %v, output: %v, expected: %v", tc.t1, tc.t2, output, tc.expected) } diff --git a/problems/merge-two-sorted-lists/merge_two_sorted_lists.go b/problems/merge-two-sorted-lists/merge_two_sorted_lists.go index c07320dc4..c80a6c0b4 100644 --- a/problems/merge-two-sorted-lists/merge_two_sorted_lists.go +++ b/problems/merge-two-sorted-lists/merge_two_sorted_lists.go @@ -1,6 +1,9 @@ package problem21 -import . "github.com/openset/leetcode/internal/kit" +import "github.com/openset/leetcode/internal/kit" + +// ListNode - Definition for singly-linked list. +type ListNode = kit.ListNode /** * Definition for singly-linked list. diff --git a/problems/merge-two-sorted-lists/merge_two_sorted_lists_test.go b/problems/merge-two-sorted-lists/merge_two_sorted_lists_test.go index e18b40844..19dcbe256 100644 --- a/problems/merge-two-sorted-lists/merge_two_sorted_lists_test.go +++ b/problems/merge-two-sorted-lists/merge_two_sorted_lists_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - . "github.com/openset/leetcode/internal/kit" + "github.com/openset/leetcode/internal/kit" ) type caseType struct { @@ -42,9 +42,9 @@ func TestMergeTwoLists(t *testing.T) { }, } for _, tc := range tests { - l1 := SliceInt2ListNode(tc.l1) - l2 := SliceInt2ListNode(tc.l2) - output := ListNode2SliceInt(mergeTwoLists(l1, l2)) + l1 := kit.SliceInt2ListNode(tc.l1) + l2 := kit.SliceInt2ListNode(tc.l2) + output := kit.ListNode2SliceInt(mergeTwoLists(l1, l2)) if !reflect.DeepEqual(output, tc.expected) { t.Fatalf("input: %v %v, output: %v, expected: %v", tc.l1, tc.l2, output, tc.expected) } diff --git a/problems/palindrome-linked-list/palindrome_linked_list.go b/problems/palindrome-linked-list/palindrome_linked_list.go index 86b048589..ef82aa4e3 100644 --- a/problems/palindrome-linked-list/palindrome_linked_list.go +++ b/problems/palindrome-linked-list/palindrome_linked_list.go @@ -1,6 +1,9 @@ package problem234 -import . "github.com/openset/leetcode/internal/kit" +import "github.com/openset/leetcode/internal/kit" + +// ListNode - Definition for singly-linked list. +type ListNode = kit.ListNode /** * Definition for singly-linked list. diff --git a/problems/palindrome-linked-list/palindrome_linked_list_test.go b/problems/palindrome-linked-list/palindrome_linked_list_test.go index ff3743874..f279a0319 100644 --- a/problems/palindrome-linked-list/palindrome_linked_list_test.go +++ b/problems/palindrome-linked-list/palindrome_linked_list_test.go @@ -3,7 +3,7 @@ package problem234 import ( "testing" - . "github.com/openset/leetcode/internal/kit" + "github.com/openset/leetcode/internal/kit" ) type caseType struct { @@ -27,7 +27,7 @@ func TestIsPalindrome(t *testing.T) { }, } for _, tc := range tests { - output := isPalindrome(SliceInt2ListNode(tc.input)) + output := isPalindrome(kit.SliceInt2ListNode(tc.input)) if output != tc.expected { t.Fatalf("input: %v, output: %v, expected: %v", tc.input, output, tc.expected) } diff --git a/problems/powerful-integers/powerful_integers_test.go b/problems/powerful-integers/powerful_integers_test.go index 13311fd19..ccd0ea49b 100644 --- a/problems/powerful-integers/powerful_integers_test.go +++ b/problems/powerful-integers/powerful_integers_test.go @@ -3,7 +3,7 @@ package problem970 import ( "testing" - . "github.com/openset/leetcode/internal/kit" + "github.com/openset/leetcode/internal/kit" ) type caseType struct { @@ -30,7 +30,7 @@ func TestPowerfulIntegers(t *testing.T) { } for _, tc := range tests { output := powerfulIntegers(tc.x, tc.y, tc.bound) - if !IsEqualSliceInt(output, tc.expected) { + if !kit.IsEqualSliceInt(output, tc.expected) { t.Fatalf("input: %v %v %v, output: %v, expected: %v", tc.x, tc.y, tc.bound, output, tc.expected) } } diff --git a/problems/range-sum-of-bst/range_sum_of_bst.go b/problems/range-sum-of-bst/range_sum_of_bst.go index 61c73ce1d..20abf84b6 100644 --- a/problems/range-sum-of-bst/range_sum_of_bst.go +++ b/problems/range-sum-of-bst/range_sum_of_bst.go @@ -1,6 +1,9 @@ package problem938 -import . "github.com/openset/leetcode/internal/kit" +import "github.com/openset/leetcode/internal/kit" + +// TreeNode - Definition for a binary tree node. +type TreeNode = kit.TreeNode /** * Definition for a binary tree node. diff --git a/problems/range-sum-of-bst/range_sum_of_bst_test.go b/problems/range-sum-of-bst/range_sum_of_bst_test.go index 3e7b91d26..25ab12147 100644 --- a/problems/range-sum-of-bst/range_sum_of_bst_test.go +++ b/problems/range-sum-of-bst/range_sum_of_bst_test.go @@ -3,7 +3,7 @@ package problem938 import ( "testing" - . "github.com/openset/leetcode/internal/kit" + "github.com/openset/leetcode/internal/kit" ) type caseType struct { @@ -16,20 +16,20 @@ type caseType struct { func TestRangeSumBST(t *testing.T) { tests := [...]caseType{ { - input: []int{10, 5, 15, 3, 7, NULL, 18}, + input: []int{10, 5, 15, 3, 7, kit.NULL, 18}, l: 7, r: 15, expected: 32, }, { - input: []int{10, 5, 15, 3, 7, 13, 18, 1, NULL, 6}, + input: []int{10, 5, 15, 3, 7, 13, 18, 1, kit.NULL, 6}, l: 6, r: 10, expected: 23, }, } for _, tc := range tests { - output := rangeSumBST(SliceInt2TreeNode(tc.input), tc.l, tc.r) + output := rangeSumBST(kit.SliceInt2TreeNode(tc.input), tc.l, tc.r) if output != tc.expected { t.Fatalf("input: %v, output: %v, expected: %v", tc.input, output, tc.expected) } diff --git a/problems/remove-duplicates-from-sorted-list/remove_duplicates_from_sorted_list.go b/problems/remove-duplicates-from-sorted-list/remove_duplicates_from_sorted_list.go index 0f006c1a7..b446d6218 100644 --- a/problems/remove-duplicates-from-sorted-list/remove_duplicates_from_sorted_list.go +++ b/problems/remove-duplicates-from-sorted-list/remove_duplicates_from_sorted_list.go @@ -1,6 +1,9 @@ package problem83 -import . "github.com/openset/leetcode/internal/kit" +import "github.com/openset/leetcode/internal/kit" + +// ListNode - Definition for singly-linked list. +type ListNode = kit.ListNode /** * Definition for singly-linked list. diff --git a/problems/remove-duplicates-from-sorted-list/remove_duplicates_from_sorted_list_test.go b/problems/remove-duplicates-from-sorted-list/remove_duplicates_from_sorted_list_test.go index 2f9a82c89..e01242985 100644 --- a/problems/remove-duplicates-from-sorted-list/remove_duplicates_from_sorted_list_test.go +++ b/problems/remove-duplicates-from-sorted-list/remove_duplicates_from_sorted_list_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - . "github.com/openset/leetcode/internal/kit" + "github.com/openset/leetcode/internal/kit" ) type caseType struct { @@ -28,8 +28,8 @@ func TestDeleteDuplicates(t *testing.T) { }, } for _, tc := range tests { - output := deleteDuplicates(SliceInt2ListNode(tc.input)) - if !reflect.DeepEqual(ListNode2SliceInt(output), tc.expected) { + output := deleteDuplicates(kit.SliceInt2ListNode(tc.input)) + if !reflect.DeepEqual(kit.ListNode2SliceInt(output), tc.expected) { t.Fatalf("input: %v, output: %v, expected: %v", tc.input, output, tc.expected) } } diff --git a/problems/reverse-linked-list/reverse_linked_list.go b/problems/reverse-linked-list/reverse_linked_list.go index 8c065c07f..b54463038 100644 --- a/problems/reverse-linked-list/reverse_linked_list.go +++ b/problems/reverse-linked-list/reverse_linked_list.go @@ -1,6 +1,9 @@ package problem206 -import . "github.com/openset/leetcode/internal/kit" +import "github.com/openset/leetcode/internal/kit" + +// ListNode - Definition for singly-linked list. +type ListNode = kit.ListNode /** * Definition for singly-linked list. diff --git a/problems/reverse-linked-list/reverse_linked_list_test.go b/problems/reverse-linked-list/reverse_linked_list_test.go index baa08d053..cc1974408 100644 --- a/problems/reverse-linked-list/reverse_linked_list_test.go +++ b/problems/reverse-linked-list/reverse_linked_list_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - . "github.com/openset/leetcode/internal/kit" + "github.com/openset/leetcode/internal/kit" ) type caseType struct { @@ -20,7 +20,7 @@ func TestReverseList(t *testing.T) { }, } for _, tc := range tests { - output := ListNode2SliceInt(reverseList(SliceInt2ListNode(tc.input))) + output := kit.ListNode2SliceInt(reverseList(kit.SliceInt2ListNode(tc.input))) if !reflect.DeepEqual(output, tc.expected) { t.Fatalf("input: %v, output: %v, expected: %v", tc.input, output, tc.expected) } diff --git a/problems/same-tree/same_tree.go b/problems/same-tree/same_tree.go index d243a9518..69c95902c 100644 --- a/problems/same-tree/same_tree.go +++ b/problems/same-tree/same_tree.go @@ -1,6 +1,9 @@ package problem100 -import . "github.com/openset/leetcode/internal/kit" +import "github.com/openset/leetcode/internal/kit" + +// TreeNode - Definition for a binary tree node. +type TreeNode = kit.TreeNode /** * Definition for a binary tree node. diff --git a/problems/same-tree/same_tree_test.go b/problems/same-tree/same_tree_test.go index c188a0100..9a6766ae0 100644 --- a/problems/same-tree/same_tree_test.go +++ b/problems/same-tree/same_tree_test.go @@ -3,7 +3,7 @@ package problem100 import ( "testing" - . "github.com/openset/leetcode/internal/kit" + "github.com/openset/leetcode/internal/kit" ) type caseType struct { @@ -21,7 +21,7 @@ func TestIsSameTree(t *testing.T) { }, { p: []int{1, 2}, - q: []int{1, NULL, 2}, + q: []int{1, kit.NULL, 2}, expected: false, }, { @@ -31,7 +31,7 @@ func TestIsSameTree(t *testing.T) { }, } for _, tc := range tests { - output := isSameTree(SliceInt2TreeNode(tc.p), SliceInt2TreeNode(tc.q)) + output := isSameTree(kit.SliceInt2TreeNode(tc.p), kit.SliceInt2TreeNode(tc.q)) if output != tc.expected { t.Fatalf("input: %v %v, output: %v, expected: %v", tc.p, tc.q, output, tc.expected) } diff --git a/problems/sum-of-root-to-leaf-binary-numbers/sum_of_root_to_leaf_binary_numbers.go b/problems/sum-of-root-to-leaf-binary-numbers/sum_of_root_to_leaf_binary_numbers.go index ba96721e6..50d5bf910 100644 --- a/problems/sum-of-root-to-leaf-binary-numbers/sum_of_root_to_leaf_binary_numbers.go +++ b/problems/sum-of-root-to-leaf-binary-numbers/sum_of_root_to_leaf_binary_numbers.go @@ -1,6 +1,9 @@ package problem1022 -import . "github.com/openset/leetcode/internal/kit" +import "github.com/openset/leetcode/internal/kit" + +// TreeNode - Definition for a binary tree node. +type TreeNode = kit.TreeNode /** * Definition for a binary tree node. diff --git a/problems/sum-of-root-to-leaf-binary-numbers/sum_of_root_to_leaf_binary_numbers_test.go b/problems/sum-of-root-to-leaf-binary-numbers/sum_of_root_to_leaf_binary_numbers_test.go index 9c675c6b6..f95ab89f0 100644 --- a/problems/sum-of-root-to-leaf-binary-numbers/sum_of_root_to_leaf_binary_numbers_test.go +++ b/problems/sum-of-root-to-leaf-binary-numbers/sum_of_root_to_leaf_binary_numbers_test.go @@ -3,7 +3,7 @@ package problem1022 import ( "testing" - . "github.com/openset/leetcode/internal/kit" + "github.com/openset/leetcode/internal/kit" ) type caseType struct { @@ -22,12 +22,12 @@ func TestSumRootToLeaf(t *testing.T) { expected: 3, }, { - input: []int{1, NULL, 0}, + input: []int{1, kit.NULL, 0}, expected: 2, }, } for _, tc := range tests { - output := sumRootToLeaf(SliceInt2TreeNode(tc.input)) + output := sumRootToLeaf(kit.SliceInt2TreeNode(tc.input)) if output != tc.expected { t.Fatalf("input: %v, output: %v, expected: %v", tc.input, output, tc.expected) } diff --git a/problems/symmetric-tree/symmetric_tree.go b/problems/symmetric-tree/symmetric_tree.go index 11085bba1..b8dca8cf1 100644 --- a/problems/symmetric-tree/symmetric_tree.go +++ b/problems/symmetric-tree/symmetric_tree.go @@ -1,6 +1,9 @@ package problem101 -import . "github.com/openset/leetcode/internal/kit" +import "github.com/openset/leetcode/internal/kit" + +// TreeNode - Definition for a binary tree node. +type TreeNode = kit.TreeNode /** * Definition for a binary tree node. diff --git a/problems/symmetric-tree/symmetric_tree_test.go b/problems/symmetric-tree/symmetric_tree_test.go index b954192dd..70c1f78f2 100644 --- a/problems/symmetric-tree/symmetric_tree_test.go +++ b/problems/symmetric-tree/symmetric_tree_test.go @@ -3,7 +3,7 @@ package problem101 import ( "testing" - . "github.com/openset/leetcode/internal/kit" + "github.com/openset/leetcode/internal/kit" ) type caseType struct { @@ -18,12 +18,12 @@ func TestIsSymmetric(t *testing.T) { expected: true, }, { - input: []int{1, 2, 2, NULL, 3, NULL, 3}, + input: []int{1, 2, 2, kit.NULL, 3, kit.NULL, 3}, expected: false, }, } for _, tc := range tests { - output := isSymmetric(SliceInt2TreeNode(tc.input)) + output := isSymmetric(kit.SliceInt2TreeNode(tc.input)) if output != tc.expected { t.Fatalf("input: %v, output: %v, expected: %v", tc.input, output, tc.expected) } diff --git a/problems/univalued-binary-tree/univalued_binary_tree.go b/problems/univalued-binary-tree/univalued_binary_tree.go index daa58ca4b..7fc4813a1 100644 --- a/problems/univalued-binary-tree/univalued_binary_tree.go +++ b/problems/univalued-binary-tree/univalued_binary_tree.go @@ -1,6 +1,9 @@ package problem965 -import . "github.com/openset/leetcode/internal/kit" +import "github.com/openset/leetcode/internal/kit" + +// TreeNode - Definition for a binary tree node. +type TreeNode = kit.TreeNode /** * Definition for a binary tree node. diff --git a/problems/univalued-binary-tree/univalued_binary_tree_test.go b/problems/univalued-binary-tree/univalued_binary_tree_test.go index d25624dec..822e212fd 100644 --- a/problems/univalued-binary-tree/univalued_binary_tree_test.go +++ b/problems/univalued-binary-tree/univalued_binary_tree_test.go @@ -3,7 +3,7 @@ package problem965 import ( "testing" - . "github.com/openset/leetcode/internal/kit" + "github.com/openset/leetcode/internal/kit" ) type caseType struct { @@ -14,7 +14,7 @@ type caseType struct { func TestIsUnivalTree(t *testing.T) { tests := [...]caseType{ { - input: []int{1, 1, 1, 1, 1, NULL, 1}, + input: []int{1, 1, 1, 1, 1, kit.NULL, 1}, expected: true, }, { @@ -27,7 +27,7 @@ func TestIsUnivalTree(t *testing.T) { }, } for _, tc := range tests { - output := isUnivalTree(SliceInt2TreeNode(tc.input)) + output := isUnivalTree(kit.SliceInt2TreeNode(tc.input)) if output != tc.expected { t.Fatalf("input: %v, output: %v, expected: %v", tc.input, output, tc.expected) }