PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/DoorDash

Evaluate a Four-Operator Expression

Last updated: Apr 12, 2026

Quick Overview

This question evaluates expression-evaluation skills such as operator precedence, integer arithmetic semantics (truncating division), and string parsing/tokenization.

  • easy
  • DoorDash
  • Coding & Algorithms
  • Software Engineer

Evaluate a Four-Operator Expression

Company: DoorDash

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Onsite

Implement a function that evaluates an arithmetic expression string containing non-negative integers, optional spaces, and the operators `+`, `-`, `*`, and `/`. There are no parentheses. Multiplication and division must be evaluated before addition and subtraction. Integer division should truncate toward zero. Function signature: `int evaluate(string s)` Examples: - `"3+2*2"` -> `7` - `" 14 - 3 / 2 "` -> `13` - `"18/3*2+5"` -> `17` Assume the input expression is always valid.

Quick Answer: This question evaluates expression-evaluation skills such as operator precedence, integer arithmetic semantics (truncating division), and string parsing/tokenization.

Related Interview Questions

  • Maximize Chef Assignment Profit - DoorDash (medium)
  • Compute Courier Delivery Pay - DoorDash (easy)
  • Compute Nearest Destination Distances - DoorDash (easy)
  • Count changed nodes between two menu trees - DoorDash (hard)
  • Calculate Daily Driver Pay - DoorDash (hard)
DoorDash logo
DoorDash
Jan 4, 2026, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
0
0
Loading...

Implement a function that evaluates an arithmetic expression string containing non-negative integers, optional spaces, and the operators +, -, *, and /.

There are no parentheses. Multiplication and division must be evaluated before addition and subtraction. Integer division should truncate toward zero.

Function signature: int evaluate(string s)

Examples:

  • "3+2*2" -> 7
  • " 14 - 3 / 2 " -> 13
  • "18/3*2+5" -> 17

Assume the input expression is always valid.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More DoorDash•More Software Engineer•DoorDash Software Engineer•DoorDash Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.