Tap here to switch tabs
Problem
Submissions

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

med
30 min
Try to solve the Form Largest Integer With Digits That Add up to Target problem.

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

med
30 min
Try to solve the Form Largest Integer With Digits That Add up to Target problem.

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