forked from liuyubobobo/Play-Leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a45d5e2
commit b46d56d
Showing
3 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
1047-Remove-All-Adjacent-Duplicates-In-String/cpp-1047/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
31
1047-Remove-All-Adjacent-Duplicates-In-String/cpp-1047/main.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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/) | | | | ||
| | | | | | | |