Merge pull request #2783 from yeahwangz/master

commit1:纠正 problems/1047.删除字符串中的所有相邻重复项.md 中 java版本 注释:将top>0纠正为top>=0   &&  commit2:纠正 0150.逆波兰表达式求值.md 的c++代码,将第21行代码的int修改为long long, 原因:既然前面考虑到可能数据值大而将int改为了long long,那么最后的RPN运算结果也 可能超过int能表示的范围
This commit is contained in:
程序员Carl
2024-10-23 09:43:39 +08:00
committed by GitHub
2 changed files with 2 additions and 2 deletions

View File

@ -108,7 +108,7 @@ public:
}
}
int result = st.top();
long long result = st.top();
st.pop(); // 把栈里最后一个元素弹出(其实不弹出也没事)
return result;
}

View File

@ -164,7 +164,7 @@ class Solution {
int top = -1;
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
// 当 top > 0,即栈中有字符时,当前字符如果和栈中字符相等,弹出栈顶字符,同时 top--
// 当 top >= 0,即栈中有字符时,当前字符如果和栈中字符相等,弹出栈顶字符,同时 top--
if (top >= 0 && res.charAt(top) == c) {
res.deleteCharAt(top);
top--;