Product
Pricing
Blog
Forum
NEW
Referral
Description
Solution
Discussion
Submissions
Ask AI
AI Insights
Quick Summary
Replace up to k non-'5' digits with '5' to maximize the resulting number.
Prioritize changing smaller digits in more significant (leftmost) positions first.
Return an empty string if k exceeds the total count of replaceable digits.
What This Tests
Greedy algorithm design and local-optimal decision making
Understanding place value impact on numeric magnitude
String iteration and character comparison techniques
Pre-validation and edge case handling
Common Patterns
Greedy
Two Pointers
Collapse
Hint
What Interviewers May Ask Next
Report
Report seen similar question in interview
Ask AI Assistant
Ask AI Assistant
Ask me anything about this coding question!
python
Auto
Debug
Run
Submit
Test Cases
Input
Output
Expected