我的LeetCode代码仓:https://github.com/617076674/LeetCode
原题链接:https://leetcode-cn.com/problems/basic-calculator-ii/description/
题目描述:

知识点:栈
思路:中缀表达式转后缀表达式+后缀表达式的计算
如何将中缀表达式转化成后缀表达式?
如何计算后缀表达式的值?
上述两个问题请见:LeetCode224——基本计算器。
时间复杂度和空间复杂度均是O(n),其中n为所给字符串表达式的长度。
JAVA代码:
public class Solution {
public int calculate(String s) {
StringBuilder stringBuilder = new StringBuilder();
Stack<Charac

该博客主要介绍了如何解决LeetCode227问题——基本计算器II。通过将中缀表达式转换为后缀表达式,并进行后缀表达式的计算。博主分享了相关思路及解题链接,提供了JAVA代码实现,时间复杂度和空间复杂度都是O(n),n代表输入字符串的长度。

1260

被折叠的 条评论
为什么被折叠?



