add new solutions

This commit is contained in:
Yiyang Kang 2026-03-19 15:29:54 +09:00
parent f297e11859
commit 4720cbefc4
8 changed files with 290 additions and 0 deletions

View file

@ -0,0 +1,25 @@
// Package q3612 implements a solution for https://leetcode.com/problems/process-string-with-special-operations-i/
package q3612
import "slices"
func processStr(s string) string {
ret := make([]byte, 0, len(s)*2)
for i := range len(s) {
switch s[i] {
case '*':
ret = ret[:max(len(ret)-1, 0)]
case '#':
ret = append(ret, ret...)
case '%':
slices.Reverse(ret)
default:
ret = append(ret, s[i])
}
}
return string(ret)
}
var _ = processStr