Search
⌘K

Leetcode 2310. Sum of Numbers With Units Digit K

Find the minimum number of positive integers (repetition allowed) whose units digit is k that sum to num, or return -1 if impossible. The problem reduces to a modular-arithmetic check: you need the smallest m (possibly 0 when num==0) such that (m*k) % 10 == num % 10 and m*k <= num, otherwise it's impossible.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.