Get Final String
Updated
Problem statement
Given a string s with uppercase English letters, remove all occurrences of the string AWS until no more remain. After each removal, the prefix and suffix strings are concatenated. Return the final string. If the final string is empty, return "-1" as a string.
Function
getFinalString(s: String) → String
Complete the function getFinalString in the editor below.
The function getFinalString has the following parameter:
string s(n): a string of uppercase English characters
Returns
string: the string after removing all occurrences of "AWS" from the given string or "-1"
Examples
Example 1
s = "AWAWSSG"return = "G"- AWAWSSG -> AWSG
- AWSG -> G
Return the final string, G.
Constraints
- 1 ≤ |s| ≤ 10^5
- The string contains only uppercase English letters.
More IBM interview questions
- Missing IntervalsOA · Seen Nov 2026
- Last Object Exit TimeOA · Seen Nov 2026
- Count Peaks and ValleysOA · Seen Nov 2026
- Count Strictly Increasing Contiguous WindowsOA · Seen Nov 2026
- Total Each Letter's Count in an Encoded StringOA · Seen Nov 2026
- Count Servers With No Requests in a Time WindowOA · Seen Nov 2026
- Alternate Odd and Even Numbers with Two GoroutinesPHONE SCREEN · Seen Nov 2026
- Longest Substring Without Repeating CharactersPHONE SCREEN · Seen Nov 2026
- Maximum Easy Tasks After RearrangingOA · Seen Nov 2026
- Longest Palindromic SubstringPHONE SCREEN · Seen Oct 2026
Similar questions at other companies
- Validate a Bracket SequenceInMobi · OAInMobi interview questions
- Valid ParenthesesBlackRock · OABlackRock interview questions
- Valid ParenthesesVanguard · OAVanguard interview questions
- Valid Bracket SequenceNVIDIA · OA · PHONE SCREENNVIDIA interview questions
- Backspace String CompareGoldman Sachs · OAGoldman Sachs interview questions
- The PromHackerEarth · OA
- Compare Character Arrays with BackspacesOdoo · OAOdoo interview questions
- Eliminate SubstringJP Morgan Chase · OAJP Morgan Chase interview questions
- Balancing ParenthesesOracle · OAOracle interview questions
- Balanced Brackets in an ExpressionBank of America · OABank of America interview questions