Problem · String

Get Final String

EasyIBMINTERNOA
See IBM hiring insights

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 Description

Complete the function getFinalString in the editor below.

The function getFinalString has the following parameter:

  1. 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
01 · 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 problems
    drafts saved locally
    public String getFinalString(String s) {
      // write your code here
    }
    
    s"AWAWSSG"
    expected"G"
    sign in to submit