EyeNewz EyeNewz

Home / Headlines

Smallest number with given digit count and sum

Geeksforgeeks · Technology · 2026-08-16

Smallest number with given digit count and sum

Given two integers s and d, find the smallest possible number that has exactly d digits and a sum of digits equal to s.Return the number as a string. If no such number exists, return "-1".Examples :Input: s = 9, d = 2Output: 18 Explanation: 18 is the smallest number

Read original on Geeksforgeeks Get the app

Licensed summary · LicensedSummary

Related briefs