Problem · String
Get Alphabetically Smallest String
Learn this problemProblem statement
Given a string S consisting of N chars, return the alphabetically smallest string that can be obtained by removing exactly one letter from S.
Function
getAlphabeticallySmallestString(S: String) → StringExamples
Example 1
S = "acb"return = "ab"By removing 1 letter, you will obtain "ac", "ab", or "cb". Your function should return "ab" (After removing 'c') since it is a alphabetically smaller than "ac" and "bc" :)
Example 2
S = "hot"return = "ho""ho" is alphabetically smaller than "ht" and "ot"
Example 3
S = "codility"return = "cdility"Obtain the answer by removing the second letter.
Example 4
S = "aaaa"return = "aaa"Any occurrence of 'a' can be removed.
Constraints
N is an integer within the range [2...100,000]string S is made only of lowercase letters (a-z)More Microsoft problems
- Maximum Pipeline ThroughputOA · Seen Jul 2026
- Maximum Strong Team SubarrayOA · Seen Jul 2026
- Minimum Cost K-Capable ModelsOA · Seen Jul 2026
- Alphabetically Smallest PalindromeOA · Seen Jul 2026
- Maximum Reward PointsOA · Seen Jul 2026
- Maximum Strength of Every NeuronOA · Seen Jul 2026
- Neural Network Subnetwork StrengthOA · Seen Jul 2026
- XOR MultiplicationOA · Seen Jul 2026