FastPrepMultiply Without the Multiplication Operator
Problems/Multiply Without the Multiplication Operator

Multiply Without the Multiplication Operator

Microsoft logoMicrosoft● EasyINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Multiplying two integers while avoiding the * operator was the one technical question in a Microsoft software engineering internship interview, according to a review.

The review gives no limits and does not say what else is allowed. Here both numbers are between -10^9 and 10^9, either may be negative, addition, subtraction and bit operations are allowed, and the product comes back as a 64-bit integer. The judge checks only the result, so the no-multiplication rule is yours to keep.

Our version is about 90% the same as the reported question.

Given two integers a and b, return their product a * b without using the multiplication operator. Addition, subtraction, comparisons and bit operations such as shifts are allowed.

The product can be as large as 10^18 in size, so return it as a 64-bit integer.

Note: the judge checks only the returned value. Not using * is the point of the exercise, but it is not checked automatically.

Function

multiply(a: int, b: int) → long

Examples

Example 1

a = 6b = 7return = 42

6 times 7 is 42.

Example 2

a = -4b = 9return = -36

Exactly one number is negative, so the product is negative: -36.

Example 3

a = -3b = -5return = 15

Both numbers are negative, so the product is positive: 15.

Constraints

  • -10^9 <= a, b <= 10^9

More Microsoft Onsite Interview questions

  • Longest Substring Without Repeating CharactersONSITE INTERVIEW · Seen Nov 2026
  • Valid ParenthesesONSITE INTERVIEW · Seen Nov 2026
  • Count a User's Actions in an Event LogONSITE INTERVIEW · Seen Nov 2026
  • Smallest Batch Size Within a Step LimitONSITE INTERVIEW · Seen Nov 2026
  • Count Subarrays with Equal Even and Odd CountsONSITE INTERVIEW · Seen Nov 2026
  • Minimum Time to Rot All OrangesONSITE INTERVIEW · Seen Nov 2026
  • Coin ChangeONSITE INTERVIEW · Seen Oct 2026
  • Daily USD Totals with Effective-Dated Exchange RatesONSITE INTERVIEW · Seen Oct 2026
  • Number Words to Digits in Any LanguageONSITE INTERVIEW · Seen Oct 2026
  • Totals from a Tiered Rate TableONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Raise a Number to an Integer PowerAdobe · PHONE SCREENAdobe interview questions
  • Find the Missing Number from 1 to nHyperVerge · ONSITE INTERVIEW
  • Swap Two Integers Without a Temporary VariableOracle · ONSITE INTERVIEWOracle interview questions
  • Add Two Binary StringsPeopleStrong · ONSITE INTERVIEWPeopleStrong interview questions
  • Check Whether a Byte Is NonzeroZscaler · ONSITE INTERVIEWZscaler interview questions
  • Fibonacci with Input ValidationMorgan Stanley · ONSITE INTERVIEWMorgan Stanley interview questions
  • Find the Lowest Set Bit PositionExpedia · OA · ONSITE INTERVIEWExpedia interview questions
  • FactorialAMD · ONSITE INTERVIEWAMD interview questions
  • Path Between Two Nodes of a Fibonacci TreeDatabricks · ONSITE INTERVIEWDatabricks interview questions
  • Bayesian Scenario ClassifierAmazon · ONSITE INTERVIEW

Interview reports that mention this question

  • Microsoft SWE Intern, Early 2026: 54 Experiences (Part 2 of 6)
  • Microsoft SWE Intern Interviews: 244 Experiences (Part 1 of 6)

Microsoft interview experiences

  • Microsoft Explore and Student SWE: 12 Experiences (Part 6 of 6)
  • Microsoft SWE Intern, Early 2025: 41 Experiences (Part 5 of 6)
  • Microsoft SWE Intern, Mid 2025: 42 Experiences (Part 4 of 6)
  • Microsoft SWE Intern, Late 2025: 47 Experiences (Part 3 of 6)
All Microsoft interview questionsSee Microsoft hiring insights
Saved
class Solution {
    public long multiply(int a, int b) {
        // Write your code here.
    }
}
Checking account…