From 7c60dee83b436e8e8a667bf9f191beced8de4fc3 Mon Sep 17 00:00:00 2001 From: Jack Sangdahl Date: Mon, 10 Mar 2025 00:36:13 -0600 Subject: chore: move cpp and rust code to directory --- other/remove_adjacent_dup_str.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 other/remove_adjacent_dup_str.cpp (limited to 'other/remove_adjacent_dup_str.cpp') diff --git a/other/remove_adjacent_dup_str.cpp b/other/remove_adjacent_dup_str.cpp new file mode 100644 index 0000000..80b61ab --- /dev/null +++ b/other/remove_adjacent_dup_str.cpp @@ -0,0 +1,20 @@ +#include "leetcode.h" + +class Solution { +public: + string removeDuplicates(string s) { + string ans; + for (char &c : s) { + if (ans.size() && c == ans.back()) + ans.pop_back(); + else + ans.push_back(c); + } + return ans; + } +}; + +int main() { + Solution obj; + cout << obj.removeDuplicates("abbaca"); +} -- cgit v1.2.3