Skip to content

Commit

Permalink
1047 added.
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyubobobo committed May 19, 2019
1 parent a45d5e2 commit b46d56d
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
cmake_minimum_required(VERSION 3.14)
project(B)

set(CMAKE_CXX_STANDARD 14)

add_executable(B main.cpp)
31 changes: 31 additions & 0 deletions 1047-Remove-All-Adjacent-Duplicates-In-String/cpp-1047/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/// Source : https://leetcode.com/problems/two-sum/description/
/// Author : liuyubobobo
/// Time : 2019-05-18

#include <iostream>

using namespace std;


/// Using Stack
/// Time Complexity: O(|S|)
/// Space Complexity: O(1)
class Solution {
public:
string removeDuplicates(string S) {

string res = "";
for(char c: S)
if(!res.size() || res.back() != c)
res += c;
else
res.pop_back();
return res;
}
};


int main() {

return 0;
}
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -730,4 +730,5 @@ email: [[email protected]](mailto:[email protected])
| 1044 | [Longest Duplicate Substring](https://leetcode.com/problems/longest-duplicate-substring/) | []<br/>[缺:后缀数组] | [C++](1044-Longest-Duplicate-Substring/cpp-1044/) | | |
| | | | | | |
| 1046 | [Last Stone Weight](https://leetcode.com/problems/last-stone-weight/) | [] | [C++](1046-Last-Stone-Weight/cpp-1046/) | | |
| 1047 | [Remove All Adjacent Duplicates In String](https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string/) | [] | [C++](1047-Remove-All-Adjacent-Duplicates-In-String/cpp-1047/) | | |
| | | | | | |

0 comments on commit b46d56d

Please sign in to comment.