Tap here to switch tabs
Problem
Submissions

Problem: Form Largest Integer With Digits That Add up to Target

Form Largest Integer With Digits That Add up to Target asks you to use digit costs to build the largest integer string with an exact total cost, or return "0" if none exists.

Statement

Given an integer array cost of size 99 and an integer target, return the largest integer as a string whose total cost equals target.

The cost of choosing the digit ii (where 1≤i≤91 \leq i \leq 9) is given by cost[i - 1]. The total cost of an integer is the sum of the costs of all its individual digits.

If no integer can be formed whose total cost equals target, return "0".

Constraints:

  • cost.length =9= 9

  • 1≤1 \leq cost[i], target ≤5000\leq 5000

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Form Largest Integer With Digits That Add up to Target

Form Largest Integer With Digits That Add up to Target asks you to use digit costs to build the largest integer string with an exact total cost, or return "0" if none exists.

Statement

Given an integer array cost of size 99 and an integer target, return the largest integer as a string whose total cost equals target.

The cost of choosing the digit ii (where 1≤i≤91 \leq i \leq 9) is given by cost[i - 1]. The total cost of an integer is the sum of the costs of all its individual digits.

If no integer can be formed whose total cost equals target, return "0".

Constraints:

  • cost.length =9= 9

  • 1≤1 \leq cost[i], target ≤5000\leq 5000