Skip to content

Commit

Permalink
add sol
Browse files Browse the repository at this point in the history
  • Loading branch information
ductnn committed Jul 2, 2024
1 parent a86abdf commit 6742376
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions leetcode/1550.ThreeConsecutiveOdds/sol.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// https://leetcode.com/problems/three-consecutive-odds/description/

package main

import (
"fmt"
)

func threeConsecutiveOdds(arr []int) bool {
cnt := 0
for _, v := range arr {
if v%2 == 1 {
cnt++
} else {
cnt = 0
}
if cnt == 3 {
return true
}
}
return false
}

func main() {
arr := []int{2,6,4,1}
fmt.Println(threeConsecutiveOdds(arr))
}

0 comments on commit 6742376

Please sign in to comment.