#3723
Maximize Sum of Squares of Digits
specialist · 740 · lc medium +31 · 58.9% accepted · 62 likes · top 56%
Description
Given positive integers num (digit count) and sum (required digit sum), return the string of a num-digit integer whose digits sum to exactly sum and whose sum of squared digits is maximized; if no such integer exists return an empty string.
Code
1
2
3