Abbreviating the Product of a Range

You are given two positive integers left and right with left <= right. Calculate the product of all integers in the inclusive range [left, right].

Since the product may be very large, you will abbreviate it following these steps:

  • Count all trailing zeros in the product and remove them. Let this count be C.
  • Denote the remaining number of digits in the product as d.
  • If d > 10, express the product as <pre>...<suf>, where <pre> denotes the first 5 digits of the product, and <suf> denotes the last 5 digits of the product after removing all trailing zeros.
  • If d <= 10, keep the remaining product unchanged.
  • Finally, represent the product as a string "<pre>...<suf>eC".

Return a string denoting the abbreviated product of all integers in the inclusive range [left, right].

Example 1
Inputleft = 1, right = 4
Output"24e0"
The product is 24, it has no trailing zeros, and since it has only 2 digits, the final representation is "24e0".
Example 2
Inputleft = 2, right = 11
Output"399168e2"
The product is 39916800; removing 2 trailing zeros gives 399168, so the abbreviated product is "399168e2".

Constraints

  • 1 <= left <= right <= 10^4

Asked at 1 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate