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