Description
Solutions
Get Alphabetically Smallest String
🔥 FULLTIME📚RELATED PROBLEMS
Given a string S consisting of N chars, return the alphabetically smallest string that can be obtained by removing exactly one letter from S.
Example 1:
Input: S = "acb"
Output: "ab"
Explanation: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:
Input: S = "hot"
Output: "ho"
Explanation:"ho" is alphabetically smaller than "ht" and "ot"
Example 3:
Input: S = "codility"
Output: "cdility"
Explanation:Obtain the answer by removing the second letter.
Example 4:
Input: S = "aaaa"
Output: "aaa"
Explanation: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)

Related Problems
Testcase
Result
Case 1
input:
output: