This commit is contained in:
Yiyang Kang 2026-02-08 15:19:01 +09:00
parent 51975f3386
commit 987c0bc36f
Signed by: kkyy
SSH key fingerprint: SHA256:lJSbAzC3MvrSORdvIVK6h/3g+rVKJNzM7zq0MgA9WKY
2 changed files with 54 additions and 0 deletions

View file

@ -0,0 +1,18 @@
package q1653
func minimumDeletions(s string) int {
bestA, bestB := 0, 0
for i := range len(s) {
switch s[i] {
case 'a':
bestB++
case 'b':
bestA, bestB = bestA+1, min(bestA, bestB)
}
}
return min(bestA, bestB)
}
var _ = minimumDeletions