LeetCode 942. 增减字符串匹配 思路双单调性 代码1234567891011121314151617class Solution {public: vector<int> diStringMatch(string s) { int top=s.length(); int bottom=0; vector<int> res(top+1); for(int i=0;i<s.length();i++){ if(s[i]=='I'){ res[i]=bottom++; }else if(s[i]=='D'){ res[i]=top--; } } res[s.length()]=top; return res; }}; [^1]: note > leetcode #code #leetcode LeetCode 942. 增减字符串匹配 https://xifenggood.github.io/2022/05/09/leetcode/942/ 作者 Jie Wang 发布于 2022年5月9日 许可协议 LeetCode 449. 序列化和反序列化二叉搜索树 上一篇 LeetCode 442. 数组中重复的数据 下一篇 Please enable JavaScript to view the comments