Multiply Two Decimal Digit Strings

Quick Overview

Multiply two nonnegative decimal strings exactly without parsing complete inputs as integers or using a built-in big-integer library.

Multiply Two Decimal Digit Strings

Company: Amazon

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Other

### Problem You receive two decimal digit strings, `left` and `right`, representing nonnegative integers. Return their exact product in decimal notation as a string. Work with the digit strings directly. You must not convert either complete input into an integer or use a built-in big-integer library. Each input uses the usual decimal representation: it has no leading zeroes unless the entire string is `"0"`. ### Examples **Example 1** ```text Input: left = "305", right = "24" Output: "7320" ``` The product of the represented numbers is `7320`. **Example 2** ```text Input: left = "0", right = "807" Output: "0" ``` Multiplying by zero gives the single-digit representation `"0"`. ### Constraints - Each input string has length between `1` and `200`, inclusive. - Both strings contain only decimal digits `0` through `9`. - A leading `0` is permitted only in the one-character string `"0"`.

Overview: Multiply two nonnegative decimal strings exactly without parsing complete inputs as integers or using a built-in big-integer library.

Amazon logo
Amazon
Date not reported
mediumSoftware EngineerOtherCoding & Algorithms
0
0

Problem

You receive two decimal digit strings, left and right, representing nonnegative integers. Return their exact product in decimal notation as a string.

Work with the digit strings directly. You must not convert either complete input into an integer or use a built-in big-integer library.

Each input uses the usual decimal representation: it has no leading zeroes unless the entire string is "0".

Examples

Example 1

Input: left = "305", right = "24"
Output: "7320"

The product of the represented numbers is 7320.

Example 2

Input: left = "0", right = "807"
Output: "0"

Multiplying by zero gives the single-digit representation "0".

Constraints

  • Each input string has length between 1 and 200 , inclusive.
  • Both strings contain only decimal digits 0 through 9 .
  • A leading 0 is permitted only in the one-character string "0" .