C++ Recursive
\nstring removeDuplicates(string S) {\n  for (auto i = 1; i < S.size(); ++i)\n    if (S[i - 1] == S[i]) \n\t  return removeDuplicates(S.substr(0, i - 1) + S.sub
```\nstring removeDuplicates(string S) {\n  for (auto i = 1; i < S.size(); ++i)\n    if (S[i - 1] == S[i]) \n\t  return removeDuplicates(S.substr(0, i - 1) + S.substr(i + 1));\n  return S;\n}\n```\nA small optimization to continue from the "cutting" point:\n```cpp\nstring removeDuplicates(string S, int i = 1) {\n  for (i = max(1, i); i < S.size(); ++i)\n    if (S[i - 1] == S[i]) \n        return removeDuplicates(S.substr(0, i - 1) + S.substr(i + 1), i - 1);\n  return S;\n}\n```\n**Complexity Analysis**\nRuntime & Memory: O(n ^ 2). We are copying the string up to n times. With a two-pointer solution, we can achieve O(n) | O(1) complexity. This solution is slow but perhaps simpler to implement.
[]