Tap here to switch tabs
Problem
Submissions

Problem: Largest Integer With Given Digit Sum

Try to solve the Largest Integer With Given Digit Sum problem.

Statement

Given two integers n and s, determine the largest nonnegative integer with at most n digits such that the sum of its digits is equal to s. If no such integer exists, return −1-1.

Constraints:

  • 1≤1 \leq n ≤5\leq 5

  • 0≤0 \leq s ≤100\leq 100

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Largest Integer With Given Digit Sum

Try to solve the Largest Integer With Given Digit Sum problem.

Statement

Given two integers n and s, determine the largest nonnegative integer with at most n digits such that the sum of its digits is equal to s. If no such integer exists, return −1-1.

Constraints:

  • 1≤1 \leq n ≤5\leq 5

  • 0≤0 \leq s ≤100\leq 100