A self-service kiosk shows its current unlock code as a positive integer with two or more digits. The kiosk's loyalty program awards a bonus: you may pick any two digit positions in the displayed code (the two positions must be different, but the digit values at those positions may happen to be equal) and the bonus equals the product of the two digits found there. Determine the largest bonus obtainable from a given code.
A single line containing one integer n.
Print a single integer: the maximum product of two digits of n taken from two different positions.
n has no leading zeros (it is written exactly as a normal positive integer, so it has between 2 and 9 digits).Example 1
Input
138
Expected
24
Explanation
The digits are 1, 3, 8. The largest two digits are 8 and 3 (from different positions), giving a bonus of 8 * 3 = 24.
Example 2
Input
907
Expected
63
Explanation
The digits are 9, 0, 7. Pairing 9 with 7 gives 63, which beats pairing either with 0, so the answer is 63.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →