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

@ -5,7 +5,7 @@ import (
)
func oddEvenJumps(A []int) int {
oddJumpMap, evenJumpMap, count, current, res := map[int]int{}, map[int]int{}, 1, 0, 0
oddJumpMap, evenJumpMap, current, res := map[int]int{}, map[int]int{}, 0, 0
for i := 0; i < len(A); i++ {
for j := i + 1; j < len(A); j++ {
if v, ok := oddJumpMap[i]; ok {
@ -42,7 +42,8 @@ func oddEvenJumps(A []int) int {
}
fmt.Printf("oddJumpMap = %v evenJumpMap = %v\n", oddJumpMap, evenJumpMap)
for i := 0; i < len(A); i++ {
count, current = 1, i
count := 1
current = i
for {
if count%2 == 1 {
if v, ok := oddJumpMap[current]; ok {

View File

@ -26,17 +26,17 @@ func Test_Problem975(t *testing.T) {
qs := []question975{
question975{
{
para975{[]int{10, 13, 12, 14, 15}},
ans975{2},
},
question975{
{
para975{[]int{2, 3, 1, 1, 4}},
ans975{3},
},
question975{
{
para975{[]int{5, 1, 3, 4, 2}},
ans975{3},
},