Class Solution
java.lang.Object
g1001_1100.s1015_smallest_integer_divisible_by_k.Solution
1015 - Smallest Integer Divisible by K.<p>Medium</p>
<p>Given a positive integer <code>k</code>, you need to find the <strong>length</strong> of the <strong>smallest</strong> positive integer <code>n</code> such that <code>n</code> is divisible by <code>k</code>, and <code>n</code> only contains the digit <code>1</code>.</p>
<p>Return <em>the <strong>length</strong> of</em> <code>n</code>. If there is no such <code>n</code>, return -1.</p>
<p><strong>Note:</strong> <code>n</code> may not fit in a 64-bit signed integer.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> k = 1</p>
<p><strong>Output:</strong> 1</p>
<p><strong>Explanation:</strong> The smallest answer is n = 1, which has length 1.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> k = 2</p>
<p><strong>Output:</strong> -1</p>
<p><strong>Explanation:</strong> There is no such positive integer n divisible by 2.</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> k = 3</p>
<p><strong>Output:</strong> 3</p>
<p><strong>Explanation:</strong> The smallest answer is n = 111, which has length 3.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= k <= 10<sup>5</sup></code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
smallestRepunitDivByK
public int smallestRepunitDivByK(int k)
-