Question: In java 8 please. Thank you Write a function solution that, given a string S consisting of N characters, returns the alphabetically smallest string that

 In java 8 please. Thank you Write a function solution that,

In java 8 please. Thank you

Write a function solution that, given a string S consisting of N characters, returns the alphabetically smallest string that can be obtained by removing exactly one letter from S. Examples: 1. Given S= "acb", by removing one letter, you can obtain "ac", "ab" or "cb". Your function should return " ab (after removing ' c ') since it is alphabetically smaller than "ac" and " bc ". 2. Given S= "hot", your function should return "ho", which is alphabetically smaller than "ht" and "ot". 3. Given S = "codility", your function should return "cdility", which can be obtained by removing the second letter. 4. Given S = "aaaa", your function should return "aaa". Any occurrence of 'a' can be removed. Write an efficient algorithm for the following assumptions: - N is an integer within the range [2.100,000]; - string S is made only of lowercase letters (az). Copyright 2009-2023 by Codility Limited. All Rights Reserved. Unauthorized copying, publication or disclosure prohibited

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!