Problem · String
Eliminate Substring
Learn this problemProblem 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"
.˚。⋆ 🌷༊ Credit to chizzy_electᯓᡣ𐭩.˚。⋆
Examples
Example 1
s = "AWAWSSG"return = "G"AWAWSSG -> AWSG -> G
Return the final string, G.Constraints
1 ≤ |s| ≤ 10^5The string contains only uppercase English letters.
More JPMorgan Chase problems
- Bitwise XOR SubsequencesOA · Seen Jul 2026
- Array ChallengeOA · Seen Jun 2026
- Minimum Cores to Handle ProcessesOA · Seen Jun 2026
- About ShippingOA · Seen Jun 2026
- Count Dropped RequestsOA · Seen Jan 2026
- Generate Table of ContentsOA · Seen Jan 2026
- Calculate Net ProfitSeen Jun 2025
- Find Total WeightSeen Jun 2025