← All problemsSign in

1015. Smallest Integer Divisible by K

LeetCodeHash TableMathOpen on judge ↗

Given a positive integer k, you need to find the length of the smallest positive integer n such that n is divisible by k, and n only contains the digit 1. Return the length of n. If there is no such n, return -1. Note: n may not fit in a 64-bit signed integer. Example 1: Input: k = 1 Output: 1 Explanation: The smallest answer is n = 1, which has length 1. Example 2: Input: k = 2 Output: -1

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start