Search
⌘K

Leetcode 2726. Calculator with Method Chaining

Implement a Calculator class whose constructor takes an initial numeric result and provides add, subtract, multiply, divide (throw "Division by zero is not allowed" for divisor 0), and power methods that each return the Calculator to allow method chaining, plus getResult to return the final value. Results within 1e-5 of the expected value are accepted.

Asked at:

Microsoft

Microsoft

Google

Google


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Early May, 2025

Microsoft

Microsoft

Mid-level

Early October, 2024

Google

Google

Mid-level

Implement a calculator to perform add, subtract, divide, modulus, multiply and power operations

Comments

Your account is free and you can post anonymously if you choose.