add new solutions
This commit is contained in:
parent
886b5e0a8e
commit
67cad91898
47 changed files with 1549 additions and 1 deletions
27
solutions/14/q1456/solution.go
Normal file
27
solutions/14/q1456/solution.go
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
package q1456
|
||||
|
||||
func isVowel(b byte) bool {
|
||||
switch b {
|
||||
case 'a', 'e', 'i', 'o', 'u':
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func maxVowels(s string, k int) int {
|
||||
maxV := 0
|
||||
curr := 0
|
||||
for i := range len(s) {
|
||||
if isVowel(s[i]) {
|
||||
curr++
|
||||
}
|
||||
if i >= k && isVowel(s[i-k]) {
|
||||
curr--
|
||||
}
|
||||
|
||||
maxV = max(curr, maxV)
|
||||
}
|
||||
return maxV
|
||||
}
|
||||
|
||||
var _ = maxVowels
|
||||
Loading…
Add table
Add a link
Reference in a new issue