diff --git a/1957. Delete Characters to Make Fancy String b/1957. Delete Characters to Make Fancy String new file mode 100644 index 0000000..77c7b3f --- /dev/null +++ b/1957. Delete Characters to Make Fancy String @@ -0,0 +1,36 @@ +class Solution { +public: + string makeFancyString(string s) { + stackst; + for(int i = 0;i=3){ + char first = st.top(); + st.pop(); + char second = st.top(); + st.pop(); + char third = st.top(); + st.pop(); + if(first == second && second == third){ + + st.push(second); + st.push(first); + }else{ + + st.push(third); + st.push(second); + st.push(first); + } + } + } + + string ans = ""; + while(!st.empty()){ + ans += st.top(); + st.pop(); + + } + reverse(ans.begin(),ans.end()); + return ans; + } +};