A number game uses cards labeled from 1 to digitCount.
Form every possible number by arranging all the cards exactly once. Sort the numbers from smallest to largest.
Find the number at the given position in the sorted order.
NumberGame
String findNumber( int digitCount, int position )
digitCount: The number of cards used in the game.position: The one-based position of the required number.Return the number at the given position as a string.
1 to digitCount.1.1 ≤ digitCount ≤ 91 ≤ position ≤ digitCount! findNumber( digitCount = 4, position = 6 )
Output: "1432"
The sixth smallest number formed using cards 1 through 4 is "1432".
findNumber( digitCount = 5, position = 73 )
Output: "41235"
The first 72 numbers begin with 1, 2, or 3. Therefore, the number at position 73 is the smallest number beginning with 4.
findNumber( digitCount = 1, position = 1 )
Output: "1"
Only one number can be formed using a single card.