Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Find the Key of the Numbers

XPChallenge Points: 10
levelLevel: Easy

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

First, convert each number into a 4-digit string.
If a number has fewer than 4 digits, add leading zeros to make it 4 digits long.

Then, form a new 4-digit result where the i-th digit is the minimum digit among the i-th digits of the three converted numbers.

Finally, return the resulting number without leading zeros. If the whole number becomes 0, return 0.

Example 1:

Input: num1 = 45, num2 = 504, num3 = 9001

Output: 4001

Explanation:

num1 → "0045" num2 → "0504" num3 → "9001" Digits: 1st: min(0,0,9) = 0 2nd: min(0,5,0) = 0 3rd: min(4,0,0) = 0 4th: min(5,4,1) = 1 → Result "0001" → return 1

Example 2:

Input: num1 = 2222, num2 = 1212, num3 = 2121

Output: 1111

Example 3:

Input: num1 = 9000, num2 = 8000, num3 = 7000

Output: 7000

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result