FastPrepSmallest String After at Most One Deletion
Problems/Smallest String After at Most One Deletion

Smallest String After at Most One Deletion

LSEG logoLSEG● EasyFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an LSEG online assessment. The task and the two examples in the report match closely. We chose the alphabet, the length limit, and the result when one character is left and removed. Our version is about 95% the same as the reported question.

Given a nonempty lowercase string s, delete at most one character while preserving the order of all other characters.

Return the lexicographically smallest possible string. Compare at the first different character; if one string is a prefix of the other, the shorter string is smaller. The empty string is allowed as a result.

Function

smallestAfterDeletion(s: String) → String

Examples

Example 1

s = "abcda"return = "abca"

Remove d from abcda to obtain abca. Deleting any earlier character makes the first differing character larger.

Example 2

s = "aaa"return = "aa"

Deleting any one a gives aa, a shorter prefix of aaa.

Example 3

s = "a"return = ""

Deleting the only character gives the empty string, which is smaller than a.

Constraints

  • 1 <= s.length <= 100000.
  • s contains only lowercase English letters.

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
  • Delete One Digit 5 to Maximize the NumberOA · Seen Feb 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 String smallestAfterDeletion(String s) {
        // write your code here
    }
}
Checking account…