FastPrepDelete One Digit 5 to Maximize the Number
Problems/Delete One Digit 5 to Maximize the Number

Delete One Digit 5 to Maximize the Number

LSEG logoLSEG● EasyFULLTIMEOA

Updated Oct 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The reported task and numeric bounds match at about 95%. The report omits the digit-presence guarantee and the empty-result and leading-zero conventions.

You are given an integer n whose decimal representation contains at least one digit 5. Delete exactly one occurrence of that digit, leaving every other digit in its original order.

Return the greatest integer you can obtain. Keep the original sign. Ignore leading zeros after deletion. If no digits remain, the result is 0.

Function

maximizeAfterDeletingFive(n: int) → int

Examples

Example 1

n = 15958return = 1958

Deleting the first 5 gives 1958; deleting the second gives 1598. The larger result is 1958.

Example 2

n = -5859return = -589

The two results are -859 and -589. Since -589 is greater, delete the second 5.

Example 3

n = 5return = 0

Deleting the only digit leaves no digits, so return 0.

Constraints

  • -99995 <= n <= 99995.
  • The decimal representation of the absolute value of n contains at least one digit 5.

More LSEG Online Assessment questions

  • Count Times Using at Most Two DigitsOA · Seen Jul 2025
  • Maximum Sum of Exactly Three Non-Adjacent ElementsOA · Seen Jul 2025
  • Maximum Word Count in a SentenceOA · Seen Jul 2025
  • Minimum Digit Swaps for the Smallest DifferenceOA · Seen Jul 2025
  • Smallest String After at Most One DeletionOA · Seen Jul 2025
  • Three-Part Partition with Minimum Largest RangeOA · Seen Feb 2025
  • Transform a String with at Most One OperationOA · Seen Feb 2025
  • Price Equity Options and ForwardsOA · Seen Dec 2024
  • Maximum Sum of Non-Adjacent ElementsOA · Seen Sep 2024
  • Return the Sentence with the Most WordsOA · Seen Sep 2024

Similar questions at other companies

  • Maximum Ones After K OperationsGoldman Sachs · OAGoldman Sachs interview questions
  • Minimum Operations to Reduce a Transaction LedgerVisa · OAVisa interview questions
  • Prepare NotificationMicrosoft · OAMicrosoft interview questions
  • Minimum Changes for Distinct Adjacent CharactersHeadlands Technologies · OAHeadlands Technologies interview questions
  • Largest Number With Even Digit FrequenciesDRW · OADRW interview questions
  • Minimum Replacements for Unequal Adjacent CharactersIBM · OAIBM interview questions
  • Crop Text at a Whole-Word BoundaryAmerican Express · OAAmerican Express interview questions
  • Minimum Flips for Even Binary RunsJP Morgan Chase · OAJP Morgan Chase interview questions
  • Missing WordsVanguard · OAVanguard interview questions
  • Digit Changes for a Multiple of 9Nutanix · OANutanix interview questions

Interview reports that mention this question

  • LSEG Graduate Technology OA and Interviews: 7 Experiences
All LSEG interview questionsSee LSEG hiring insights
Saved
class Solution {
    public int maximizeAfterDeletingFive(int n) {
            // write your code here
        }
}
Checking account…