JuniorMath

Find the Key of the Numbers

You are given three positive integers num1, num2, and num3.

The key of num1, num2, and num3 is defined as a four-digit number such that:

  • Initially, if any number has less than four digits, it is padded with leading zeros.
  • The i^th digit (1 <= i <= 4) of the key is generated by taking the smallest digit among the i^th digits of num1, num2, and num3.

Return the key of the three numbers without leading zeros (if any).

Example 1
Inputnum1 = 1, num2 = 10, num3 = 1000
Output0
After padding, the digit-wise minimum forms "0000", which is returned as 0 without leading zeros.
Example 2
Inputnum1 = 987, num2 = 879, num3 = 798
Output777
Comparing the padded numbers digit by digit gives the key "0777", which is returned as 777 without the leading zero.

Constraints

  • 1 <= num1, num2, num3 <= 9999

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