FastPrepEvaluate Parenthesized Addition and Subtraction
Problems/Evaluate Parenthesized Addition and Subtraction

Evaluate Parenthesized Addition and Subtraction

Roblox logoRoblox● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The named Basic Calculator family matches at about 80%. The report gives no literal expressions. We chose how plus and minus group, the rules for a unary minus, spaces, decimal zeros, and the limits. All examples are ours. Our version is about 80% the same as the reported question.

Evaluate a valid integer expression containing additions, subtractions and parenthesized groups, and return its integer value.

For this exercise, assume an expression starts with a factor and may continue with + or - followed by another factor. A factor is a nonnegative decimal integer or an expression in parentheses. It may have one unary minus before it. ASCII spaces may occur between tokens; leading zeroes are decimal. Input is valid and nonempty. Multiplication, division, unary plus and invalid-input handling are outside this contract.

For this exercise, assume length at most 500, nesting depth at most 50, literals 0 through 1000000 and signed 32-bit intermediate/final values.

Function

evaluateParenthesized(expression: String) → int

Examples

Example 1

expression = "8-(3-2)"return = 7

Subtracting the entire grouped result gives 7.

Example 2

expression = "-(2+3)+10"return = 5

Unary minus applies to the whole group; the result is 5.

Example 3

expression = "1-(-2)+4"return = 7

Subtracting a negative factor gives 7.

Constraints

  • For this exercise, assume 1 <= expression.length <=500 and nesting depth at most 50.
  • Every literal is from 0 through 1000000 and all intermediate/final results fit signed 32-bit integers.
  • Only the declared valid decimal/plus/minus/parenthesis/unary-minus grammar is admitted.

More Roblox Phone Screen questions

  • Most Frequent Call Path From Function Trace LogsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Design Search Autocomplete SystemPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Candy Crush Grid Matching and GravityPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Implement a Rate LimiterPHONE SCREEN · Seen Oct 2026
  • Rate Limit by Multiple Request FieldsPHONE SCREEN · Seen Oct 2026
  • Topological Sort with Secondary OrderingPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Time-Aware Search AutocompletePHONE SCREEN · Seen Oct 2026
  • Most Frequent Call Stack Per ThreadPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Rate Limiter Sliding Window With Per-Entity LimitsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Closest Binary Search Tree Value — Base PracticePHONE SCREEN · Seen Jun 2026

Similar questions at other companies

  • Basic Calculator IISnap Inc. · PHONE SCREENSnap Inc. interview questions
  • Simplify a Nested Variable ExpressionGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Simplify a Formula with Known and Unknown VariablesBetter.com · PHONE SCREEN
  • Evaluate Parenthesized Addition and SubtractionAtlassian · PHONE SCREENAtlassian interview questions
  • Stack Formula InterpreterTypeSafe AI · PHONE SCREEN
  • Calculate a Token-List ExpressionCollege Vine · ONSITE INTERVIEW
  • Adjacent Equal-Pair Removal GameZipRecruiter · OAZipRecruiter interview questions
  • Smallest Value for a Linear Expression ModuloIntel · OA
  • Adjacent Pair and Run RemovalWhatNot · PHONE SCREEN · ONSITE INTERVIEWWhatNot interview questions
  • Evaluate an Arithmetic Expression Written in WordsBrex · PHONE SCREEN

Roblox interview experiences

  • Roblox OA: What It Tests (2026)
  • Roblox New Grad Early OA Tasks: 10 Experiences (Part 7 of 7)
  • Roblox New Grad Engineer Rounds: 13 Experiences (Part 6 of 7)
  • Roblox New Grad HackerRank OA: 18 Experiences (Part 5 of 7)
  • Roblox New Grad CodeSignal Finals: 23 Experiences (Part 4 of 7)
  • Roblox New Grad Games and BQ: 25 Experiences (Part 3 of 7)
All Roblox interview questionsSee Roblox hiring insights
Saved
class Solution {
    public int evaluateParenthesized(String expression) {
        // Write your code here.
        return 0;
    }
}
Checking account…