Practice Sum of Numbers With Units Digit K
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Medium#2310
LeetCode ProblemSum of Numbers With Units Digit K
Problem Statement
Choose positive integers, allowing repeated values, whose units digits are all k and whose total is num. Return the smallest number of selected integers, or -1 if impossible. Selecting no integers is allowed and has sum 0.
Source: Sum of Numbers With Units Digit K on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
num = 58, k = 9
Output
2
# Example 2
Input
num = 37, k = 2
Output
-1
# Example 3
Input
num = 0, k = 7
Output
0
Constraints
0 <= num <= 3000
0 <= k <= 9
Related LeetCode Problems
Practice more problems similar to Sum of Numbers With Units Digit K.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.