Add solution 0368、0377、0696

This commit is contained in:
YDZ
2021-04-24 21:04:28 +08:00
parent 1cdbefdc9c
commit 45fb40ee7f
38 changed files with 1371 additions and 665 deletions

View File

@ -0,0 +1,21 @@
package leetcode
func countBinarySubstrings(s string) int {
last, res := 0, 0
for i := 0; i < len(s); {
c, count := s[i], 1
for i++; i < len(s) && s[i] == c; i++ {
count++
}
res += min(count, last)
last = count
}
return res
}
func min(a, b int) int {
if a < b {
return a
}
return b
}