FastPrepProduct of Two Integers Without Multiplying
Problems/Product of Two Integers Without Multiplying

Product of Two Integers Without Multiplying

Capital One logoCapital One● MediumNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A 2018 Capital One report from a graduate software developer candidate in the United Kingdom lists a short coding task from its assessment process. The task is to multiply two numbers without the language's built-in multiplication.

The report does not say which numbers or which other operations are allowed. Here the inputs are any two 32-bit integers, signs included, and the answer is a 64-bit integer. The editorial avoids multiplication and division, using addition, negation, bit operations and comparisons. Outputs cannot show which operators were used, so the editorial code demonstrates the restriction. These are our choices.

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

Compute a times b. The catch: the * operator, division and any library call that multiplies are off limits, so build the product with +, -, unary minus, <<, >>, & and comparisons. Either factor can be negative or zero, and the answer may need 64 bits, so return a long.

Function

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

Examples

Example 1

a = 13b = -6return = -78

13 + 13 + 13 + 13 + 13 + 13 = 78. The signs of the two factors differ, which turns the result into -78.

Example 2

a = 0b = 2147483647return = 0

Anything times zero is zero.

Example 3

a = -2147483648b = -1return = 2147483648

The product is 2147483648, one more than the largest 32-bit integer, which is why the answer is a 64-bit integer.

Constraints

  • -2^31 <= a, b <= 2^31 - 1

More Capital One Onsite Interview questions

  • Digit-Coded Card ValidationONSITE INTERVIEW · Seen Nov 2026
  • Sort ColorsONSITE INTERVIEW · Seen Oct 2026
  • Virtual Card Transaction ValidatorONSITE INTERVIEW · Seen Oct 2026
  • Banking System with Top ActivityONSITE INTERVIEW · Seen Sep 2026
  • Transaction Event StoreONSITE INTERVIEW · Seen Jul 2026
  • Shortest Path in an Unweighted GraphONSITE INTERVIEW · Seen Jul 2026
  • Duplicate Transactions Within 60 SecondsONSITE INTERVIEW · Seen May 2026
  • LRU CachePHONE SCREEN · ONSITE INTERVIEW · Seen May 2026
  • Cashback TrackerONSITE INTERVIEW · Seen Nov 2025
  • Reverse a StringOA · ONSITE INTERVIEW · Seen Oct 2025

Similar questions at other companies

  • Bayesian Scenario ClassifierAmazon · ONSITE INTERVIEW
  • First Register Overflow TickNVIDIA · ONSITE INTERVIEWNVIDIA 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
  • Add BinaryMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Check Whether a Byte Is NonzeroZscaler · ONSITE INTERVIEWZscaler interview questions
  • K-th Amount a Payout Machine Can GiveRippling · ONSITE INTERVIEWRippling interview questions
  • Find the Lowest Set Bit PositionExpedia · OA · ONSITE INTERVIEWExpedia interview questions
  • Knights, Knaves and Their StatementsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions

Capital One interview experiences

  • Capital One Coding OA Questions: 3 Experiences
  • Capital One Experienced Engineer Power Day and OA: 6 Experiences
  • Capital One New Grad OA Questions: 14 Experiences (Part 2 of 2)
  • Capital One TDP Agentic Round (AI Coding): 7 Experiences
  • Capital One SWE Power Day, Level Not Reported: 6 Experiences
  • Capital One TIP Intern OA and Power Day: 13 Experiences
All Capital One interview questionsSee Capital One hiring insights
Saved
class Solution {
    public long multiply(int a, int b) {
        // Write your code here.
    }
}
Checking account…