Skip to main content
Basic Calculator | AlgoCracked
AlgoCracked
ProblemsBasic Calculator
Hard43.0% acceptance
MathStringStackRecursion

Basic Calculator

Given a string s representing a valid arithmetic expression built from digits, + , - , ( , ) and spaces, evaluate it and return the result as an integer. You must implement the evaluation yourself (no built-in eval ). Only addition and subtraction appear, but parentheses can nest to any depth, and - may act as a unary minus (e.g. -(2+3) ). Input format Input is [s] , e.g. [ (1+(4+5+2)-3)+(6+8) ] .

Loading workspace…