mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-19 21:31:22 +08:00
Merge pull request #60 from halfrost/code_quality_improvement
optimization code quality level from A to A+
This commit is contained in:
@ -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
|
||||
|
@ -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},
|
||||
},
|
||||
|
Reference in New Issue
Block a user