Re: [閒聊] 每日leetcode

作者: smart0eddie (smart0eddie)   2024-07-12 14:53:46
2024-07-12
1717. Maximum Score From Removing Substrings
You are given a string s and two integers x and y. You can perform two types
of operations any number of times.
Remove substring "ab" and gain x points.
For example, when removing "ab" from "cabxbae" it becomes "cxbae".
Remove substring "ba" and gain y points.
For example, when removing "ba" from "cabxbae" it becomes "cabxe".
Return the maximum points you can gain after applying the above operations on
s.
抄解答.jpg
因為是要砍ab 或 ba
所以只處理a 或 b
ab 分數高就優先砍 ab 否則就先累積著
反之亦然
碰到不是 a, b 的東西的時候
因為絕對不會被消耗掉
所以要把之前累積的 a, b 清空
作者: oin1104 (是oin的說)   2024-07-12 15:05:00
大師

Links booklink

Contact Us: admin [ a t ] ucptt.com