EASY TWO POINTER SOLUTION
\n# Approach\nInitialize two pointers, i and j, both pointing to the first and second characters of the string s, respectively.\n\nUse a while loop to iterate t
\n# Approach\nInitialize two pointers, i and j, both pointing to the first and second characters of the string s, respectively.\n\nUse a while loop to iterate through the string while j is within the valid index range (0 to s.length() - 1).\n\nCheck if the characters at indices i and j are the same. If they are, it means we have found a duplicate pair.\n\nWhen a duplicate pair is found, use the erase function to remove both characters from the string s. Since the erase function modifies the string in place, the characters at indices i and j will be removed.\n\nAdjust the pointers i and j to continue searching for adjacent duplicates:\n\nMove i one step back (i = max(0, i - 1)) to check if there are any duplicates before the previously deleted pair.\nMove j one step back (j = max(1, j - 1)) to continue the search from the updated position of i.\nIf the characters at indices i and j are different, move both pointers i and j one step forward to check the next pair of characters.\n\nRepeat steps 3 to 6 until all characters in the string have been checked.\n\nReturn the updated string after all adjacent duplicates have been removed.\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:0(N*N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:0(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    string removeDuplicates(string s)\n    {\n        int i = 0;\n        int j = 1;\n        while (j < s.length())\n        {\n            if (s[i] == s[j])\n            {\n                s.erase(i, 2);\n                i = max(0, i - 1);\n                j = max(1, j - 1);\n            } \n            else\n            {\n                i++;\n                j++;\n            }\n        }\n        return s;\n    }\n};\n\n```
['Two Pointers', 'String', 'C++']