Remove Spaces (LaiCode)

class Solution { public: string removeSpaces(string input) { // write your solution here string res = ""; for (auto & c : input){ if (c != ' ' || res.back() != ' ') res.push_back(c); } return res; } };

1 Response

The problem description is ambiguous.

Write a comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.