Skip to content

Instantly share code, notes, and snippets.

@mumunuu
Created June 8, 2021 02:48
Show Gist options
  • Save mumunuu/f039366bda8a6ee98d61c005695f8691 to your computer and use it in GitHub Desktop.
Save mumunuu/f039366bda8a6ee98d61c005695f8691 to your computer and use it in GitHub Desktop.
1869. Longer Contiguous Segments of Ones than Zeros
func checkZeroOnes(s string) bool {
oneLen := getLongest(s, "1")
zeroLen := getLongest(s, "0")
if oneLen > zeroLen {
return true
}
return false
}
func getLongest(s, flag string) int {
for i := len(s); i > 0; i-- {
if strings.Index(s, strings.Repeat(flag, i)) != -1 {
return i
}
}
return 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment