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^thdigit (1 <= i <= 4) of thekeyis generated by taking the smallest digit among thei^thdigits ofnum1,num2, andnum3.
Return the key of the three numbers without leading zeros (if any).
Example 1
Input
num1 = 1, num2 = 10, num3 = 1000Output
0After padding, the digit-wise minimum forms "0000", which is returned as 0 without leading zeros.
Example 2
Input
num1 = 987, num2 = 879, num3 = 798Output
777Comparing 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