← Questions

Delete one '5' from a digit string to get the largest number

0
CohereCodingLast asked Sep 2026

You get a string of decimal digits that contains at least one '5'. Remove exactly one of the '5' characters so that the number left is as large as possible, and return that string. Explain why a greedy choice of which '5' to drop is correct, and give the running time.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding