2024-01-10发表2024-01-10更新LeetCode每日一题几秒读完 (大约96个字)0次访问2696. 删除子串后的字符串最小长度2696. 删除子串后的字符串最小长度 难度: easy 原始链接: https://leetcode.cn/problems/minimum-string-length-after-removing-substrings 标签: 栈 解法一: 栈go123456789101112func minLength(s string) int { stack := []byte{} n := len(s) for i := 0; i < n; i++ { if len(stack) > 0 && (s[i] == 'B' && stack[len(stack) - 1] == 'A' || s[i] == 'D' && stack[len(stack) - 1] == 'C') { stack = stack[:len(stack) - 1] } else { stack = append(stack, s[i]) } } return len(stack)}2696. 删除子串后的字符串最小长度https://wuhunyu.top/leetcode/2024/01/minimum-string-length-after-removing-substrings/index.html作者wuhunyu发布于2024-01-10更新于2024-01-10许可协议#栈