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.
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
01 · Example 1
s = "AWAWSSG" return = "G"
Constraints
More IBM problems
- Count Descending SubarraysOA · Seen Apr 2026
- Count Power Products in RangeOA · Seen Apr 2026
- Minimum Operations to Make Alternating Binary StringSeen Feb 2026
- Minimum Number of Non-Empty Disjoint SegmentsSeen Feb 2026
- Count Unstable ProcessesOA · Seen Feb 2026
- Longest Balanced Binary SubarrayOA · Seen Feb 2026
- Process Execution TimeOA · Seen Nov 2025
- Service Timeout DetectionOA · Seen Nov 2025
public String getFinalString(String s) {
// write your code here
}
s"AWAWSSG"
expected"G"
sign in to submit