153. Remove All Spaces from a String

EasyStringString

Given a string s, remove all space characters (' ') from it and return the resulting string.

Only ASCII space characters (U+0020) should be removed. Tabs, newlines, and other whitespace are NOT considered spaces for this problem.

Input: A single string s.

Output: The string with all space characters removed.

Examples

Example 1
Input: hello world
Output: helloworld
Explanation: The single space between 'hello' and 'world' is removed.
Example 2
Input:   both sides  
Output: bothsides
Explanation: Leading and trailing spaces as well as inner spaces are all removed.
Example 3
Input: nospace
Output: nospace
Explanation: No spaces present; the string is returned unchanged.

Constraints

Asked by

TCSInfosysWiproCognizantCapgemini
Solve this problem in the editor →