Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Search
⌘K
Get Premium
Leetcode 1449. Form Largest Integer With Digits That Add up to Target
Given costs for digits 1–9 and a total budget target, return the largest possible positive integer (as a string) whose digits' costs sum exactly to target, or "0" if impossible. This is an exact-knapsack dynamic programming problem: maximize the number (length) of digits and then pick the lexicographically/largest numeric arrangement (prefer higher digits) while ensuring feasibility for the remaining cost.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.