Multiply Strings
Updated
Problem statement
Given two non-negative integers num1 and num2 written as strings of digits, return their product, also written as a string.
The answer has no leading zeros, so a product of zero is "0".
Work with the digits yourself: do not use a built-in library for big integers, and do not turn either string into a number in one step.
Function
multiply(num1: String, num2: String) → StringExamples
Example 1
num1 = "46"num2 = "25"return = "1150"46 × 25 = 1150.
Example 2
num1 = "9999999999"num2 = "9999999999"return = "99999999980000000001"Each input has 10 digits and the product has 20. That is too large for a 64-bit integer, whose largest value has 19 digits.
Example 3
num1 = "0"num2 = "9081"return = "0"Any number times 0 is 0. The answer is "0", not a string of several zeros.
Constraints
1 <= num1.length, num2.length <= 200num1andnum2hold only the digits0to9.- Neither
num1nornum2starts with0, except the number"0"itself.
More Zillow Phone Screen questions
- Valid ParenthesesPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2025
- Time Based Key-Value StorePHONE SCREEN · Seen Feb 2024
- Filter Formatted Records by CriteriaPHONE SCREEN · Seen Sep 2023
- Build a Hash TablePHONE SCREEN · ONSITE INTERVIEW · Seen Feb 2023
- Jump GamePHONE SCREEN · Seen Dec 2022
- Reversible Run-Length EncodingPHONE SCREEN · Seen Nov 2022
- Spiral MatrixPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2022
- Two Sum: All PairsPHONE SCREEN · Seen Nov 2022
- Employee Free TimePHONE SCREEN · Seen Oct 2022
- First Unique Character in a StringPHONE SCREEN · Seen Oct 2022
Similar questions at other companies
- Add Signed Character ArraysByteDance · PHONE SCREENByteDance interview questions
- Per-Segment SpeedingOnePay · PHONE SCREENOnePay interview questions
- Add Decimal Strings ExactlyMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
- Format a Centered Pagination BarMixpanel · PHONE SCREENMixpanel interview questions
- Subtract Two Large Number StringsStackAdapt · PHONE SCREENStackAdapt interview questions
- Fair Coin from a Biased CoinAnthropic · PHONE SCREENAnthropic interview questions
- Add Two Integers Given as StringsJane Street · PHONE SCREENJane Street interview questions
- Fizz and Buzz Words From 1 to nDocuSign · PHONE SCREENDocuSign interview questions
- Fizz BuzzBloomberg LP · PHONE SCREENBloomberg LP interview questions
- Double-Base PalindromesxAI · PHONE SCREENxAI interview questions