Question
Remove Spaces

Given a string s, remove all spaces from it.

This includes:

  • Single spaces
  • Multiple spaces
  • Leading and trailing spaces

You must output the string without any spaces. Use of any in-built methods like split() is not allowed.

Input
A single string s.
Output
Print the string s with all spaces removed.
Example
Example 1
Input:
hello world
Output:
helloworld

Explanation:
The string contains multiple spaces between hello and world.
After removing all spaces, the final string becomes:
helloworld

Example 2
Input:
a b c
Output:
abc

Explanation:
The string has leading spaces, single spaces, and multiple spaces.
After removing all of them, the final output is:
abc

Online