From 7eee5a78005a9a569186d2c8b4b645a818ab9bf1 Mon Sep 17 00:00:00 2001 From: Stoycho Kyosev Date: Sun, 6 Oct 2024 07:04:44 -0400 Subject: Cleanup --- Seminar02/task01.cpp | 51 --------------------------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 Seminar02/task01.cpp (limited to 'Seminar02/task01.cpp') diff --git a/Seminar02/task01.cpp b/Seminar02/task01.cpp deleted file mode 100644 index 288b3b5..0000000 --- a/Seminar02/task01.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include -#include -#include - -std::string removeStars(const std::string& s) { - std::stack st; - - for (int i = 0; i < s.size(); i++) { - if (s[i] == '*') { - if (st.empty()) - throw "invalid expr"; - else - st.pop(); - } - else - st.push(s[i]); - } - - std::string res(st.size(), '\0'); - size_t idx = st.size() - 1; - - while (!st.empty()) { - res[idx--] = st.top(); - st.pop(); - } - - return res; -} - -std::string removeStarsTwo(const std::string& str) { - // As we are using only push_back and pop_back here - // the std::string is equivalent to a stack - // and we save up some time and memory. - std::string result; - - for(char c : str) { - if(c == '*') { - result.pop_back(); - } - else { - result.push_back(c); - } - } - - return result; -} - - -int main() { - -} -- cgit v1.3.1-23-gd82d