All problems
0156MediumMathStringSimulation

Punched Reel Product

Tracked in this browser only
Write code

Trains the technique from

LeetCode 43Multiply Strings

This is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.

Same function shape, different story and different numbers.

A stock-take terminal reads tallies off punched paper reels. A reel is written as a run of digit characters, heaviest digit first, and a reel can hold far more digits than any number type on the terminal can carry.

You are handed the reels left_reel and right_reel. Punch and return the reel that records their product. The digits are all you get to work with: feeding either reel into a built-in numeric type, or handing the job to a big-number library, is not allowed.

A reel never starts with a padding zero, the one exception being the single-digit reel "0", which stands for an empty tally. Your answer must obey the same rule.

Examples

Example 1

Input
left_reel = "47", right_reel = "206"
Output
"9682"

Column by column, 47 punched 206 times over lands on 9682, and no padding zero is needed in front.

Example 2

Input
left_reel = "70", right_reel = "30"
Output
"2100"

70 punched 30 times over lands on 2100. The trailing zero of each reel carries through to the answer, and no padding zero is written in front of it.

Example 3

Input
left_reel = "0", right_reel = "5814"
Output
"0"

An empty tally on one reel empties the product, and the answer is punched as the single digit 0 rather than a run of zeros.

Constraints

  • 1 <= left_reel.length, right_reel.length <= 200
  • left_reel and right_reel hold digit characters only
  • Neither reel starts with a zero unless the reel is exactly "0"

The signature

The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.

Python
def reel_product(left_reel: str, right_reel: str) -> str:
Java
public String reelProduct(String leftReel, String rightReel)
September 7
Apply