Recover the original song by collapsing repeated remix separators into single word separators.
A song was remixed by inserting the word WUB many times into the original lyrics. To restore the original song, remove every occurrence of WUB and place a single space between consecutive words that were separated by one or more WUBs.
Given the remixed string, output the original lyrics with words separated by single spaces only.
WUB may appear at the beginning, middle, or end of the string.WUB should still result in just one space between adjacent words.A single string s representing the remixed song.
Print the restored original song with words separated by single spaces and no leading or trailing spaces.
1 <= |s| (length is finite and manageable for standard string processing)s contains only uppercase Latin lettersWUB may appear multiple timesExample 1
Input
WUBWUBABCWUB
Output
ABC
Explanation
All WUB blocks are removed, leaving a single word.
Example 2
Input
WUBWUBABCWUBWUBDEFWUB
Output
ABC DEF
Explanation
The remaining words are ABC and DEF, separated by a single space.
Example 3
Input
WUBABCWUBDEFWUBGHI
Output
ABC DEF GHI
Explanation
Each run of WUB acts as one separator between words.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.