FastPrepGet Final String
Problems/Get Final String

Get Final String

IBM logoIBM● EasyINTERNOA

Updated Sep 2026

QuestionFunctionExamplesConstraints

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:

  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

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

IBM interview experiences

  • IBM Full-Time SWE OA Questions: 1 Experience
  • IBM Software Intern Résumé Rounds: 2 Experiences (Part 3 of 3)
  • IBM Intern Blitz Interviews: 23 Experiences (Part 2 of 3)
  • IBM Software Intern Interviews: 44 Experiences (Part 1 of 3)
  • IBM Software Intern Interview Questions: 15 Experiences
All IBM interview questionsSee IBM hiring insights
Saved
class Solution {
    public String getFinalString(String s) {
      // write your code here
    }

}
Checking account…