Explanation

589.Remove All Spaces from a String

Easy
Given a string text, return it with every space removed — at the start, the end and in the middle. Removing characters is a filter: walk through the input and copy only what you want to keep. Unlike trimming, which only looks at the two ends, this visits every character. In C it introduces a write indexWrite IndexA separate position that marks where the next kept item is written, so filtered output has no gaps. that moves more slowly than the read index.

Example 1:

Input: text = "a b c"

Output: "abc"

Example 2:

Input: text = "nospace"

Output: "nospace"

+ 4 hidden test cases run on Submit.

Constraints:

  • ●1 ≤ text.length ≤ 1000
  • ●text contains printable ASCII characters

text =

a b c