FastPrepEvaluate a Flat Addition and Subtraction Expression
Problems/Evaluate a Flat Addition and Subtraction Expression

Evaluate a Flat Addition and Subtraction Expression

Atlassian logoAtlassian● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The reported flat addition/subtraction capability matches at about 90%; explicit valid syntax, spacing, decimal zeroes, unsigned literals, unary-sign exclusion and finite bounds define the practice version.

Given expression, evaluate its decimal integer additions and subtractions from left to right and return the integer result.

For this exercise, assume the expression is valid and nonempty: it starts with an unsigned integer and may continue with + or - followed by another unsigned integer. ASCII spaces may occur between tokens, and leading zeroes are interpreted as decimal. Unary signs, parentheses, multiplication, division and invalid-input handling are outside the scope of this problem.

For this exercise, assume a length of at most 500, literals from 0 through 1000000, and all intermediate/final results within signed 32-bit range.

Function

evaluateFlat(expression: String) → int

Examples

Example 1

expression = "3+2-4"return = 1

Adding and subtracting from left to right, the expression evaluates to 1.

Example 2

expression = "10 - 20 + 3"return = -7

The result is negative; spaces occur between tokens.

Example 3

expression = "005 + 12 - 0007"return = 10

Leading zeroes are treated as decimal digits.

Constraints

  • For this exercise, assume 1 <= expression.length <= 500.
  • Every literal is a decimal integer from 0 through 1000000.
  • Only binary plus/minus and optional ASCII spaces occur; input is always syntactically valid.
  • All intermediate and final values fit a signed 32-bit integer.

More Atlassian Phone Screen questions

  • Merge Overlapping IntervalsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Tennis Court SchedulingPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Implement a Rate LimiterPHONE SCREEN · Seen Oct 2026
  • Longest Consistent Activity StreakPHONE SCREEN · Seen Sep 2026
  • Music Player Operation SequencePHONE SCREEN · Seen Sep 2026
  • Underline Shortest Unique SubstringsPHONE SCREEN · Seen Aug 2026
  • Can a Dictionary Word Be Formed from Note Letters?PHONE SCREEN · Seen Feb 2026
  • Word Path Moving Only Right or DownPHONE SCREEN · Seen Feb 2026
  • Ordered Badge Entry and Exit ViolationsPHONE SCREEN · Seen Aug 2025
  • Two Sum with an Ordered Index PairPHONE SCREEN · Seen Aug 2025

Similar questions at other companies

  • Transaction Fee Calculator — Parts 1–2: Basic Fee Calculation and Conditional Fee RulesStripe · PHONE SCREENStripe interview questions
  • Subtract Two Large Number StringsStackAdapt · PHONE SCREENStackAdapt interview questions
  • Fair Coin from a Biased CoinAnthropic · PHONE SCREENAnthropic interview questions
  • Stack Formula InterpreterTypeSafe AI · PHONE SCREEN
  • Roman to IntegerKotak Mahindra Bank · PHONE SCREEN · ONSITE INTERVIEWKotak Mahindra Bank interview questions
  • Minimum Difference Between Two Clock TimesMicron Technology · PHONE SCREEN
  • Decimal Digits in OrderZoomInfo · PHONE SCREEN
  • Add Two Integers Given as StringsJane Street · PHONE SCREENJane Street interview questions
  • Fizz and Buzz Words From 1 to nDocuSign · PHONE SCREENDocuSign interview questions
  • Integer to String Without Built-insHudson River Trading · PHONE SCREENHudson River Trading interview questions

Atlassian interview experiences

  • Atlassian MLE Phone Screen: Model Deployment Design: 1 Experience
  • Atlassian Coding Screens and Karat: 3 Experiences (Part 2 of 2)
  • Atlassian Full Stack Interviews: 11 Experiences (Part 1 of 2)
All Atlassian interview questionsSee Atlassian hiring insights
Saved
class Solution {
    public int evaluateFlat(String expression) {
        // Write your code here.
        return 0;
    }
}
Checking account…