leetcode 1544. 整理字符串-耗时100-Make The String Great

📅 发布时间:2026/7/16 22:15:41 👁️ 浏览次数:
leetcode 1544. 整理字符串-耗时100-Make The String Great
Problem: 1544. 整理字符串-Make The String Great耗时100%字符串string实例化当作栈来使用首先确定相同字符不同大小写的绝对值距离cCodeclass Solution { public: string makeGood(string s) { int c abs(A - a), n s.size(); string ret; char ch; for(int i 0; i n; i) { ch s[i]; if(ret.size() 0 abs(ret.back() - ch)c) { ret.pop_back(); continue; } ret ch; } return ret; } };