Harpreet's Newsletter

Harpreet's Newsletter

Basic Calculator II

Amazon’s Largest Layoffs Ever

Harpreet Singh's avatar
Harpreet Singh
Oct 31, 2025
∙ Paid

Problem Overview

Difficulty: Medium
LeetCode Pattern: Stack

Given a string s which represents an expression, evaluate this expression and return its value.

Note: The integer division should truncate toward zero.

Input: s = “3+2*2”
Output: 7

Input: s = “ 3/2 “
Output: 1

Input: s = “ 3+5 / 2 “
Output: 5
User's avatar

Continue reading this post for free, courtesy of Harpreet Singh.

Or purchase a paid subscription.
© 2026 Harpreet Singh · Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture