Given a positive integer k, find the length of the smallest positive integer n such that n is divisible by k and n contains only the digit 1. Return that length, or -1 if no such n exists. Note that n may not fit in a 64-bit signed integer.
Given a positive integer k, find the length of the smallest positive integer n such that n is divisible by k and n contains only the digit 1. Return that length, or -1 if no such n exists. Note that n may not fit in a 64-bit signed integer.
Example 1:
Input: {"k":1}
Output: 1
Constraints:
1≤k≤105
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"k":1}
Look for the shortest number made only of 1s (1, 11, 111, ...) that k = 1 divides. Those numbers explode in size, so track only their remainder mod k.