Merge pull request #60 from halfrost/code_quality_improvement

optimization code quality level from A to A+
This commit is contained in:
halfrost
2020-08-27 01:07:57 +08:00
committed by YDZ
543 changed files with 2449 additions and 2396 deletions

View File

@ -4,9 +4,9 @@ func removeDuplicates80(nums []int) int {
if len(nums) == 0 {
return 0
}
last, finder, startFinder := 0, 0, -1
last, finder := 0, 0
for last < len(nums)-1 {
startFinder = -1
startFinder := -1
for nums[finder] == nums[last] {
if startFinder == -1 || startFinder > finder {
startFinder = finder

View File

@ -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},
},