diff --git a/1119-Remove-Vowels-from-a-String/cpp-1119/CMakeLists.txt b/1119-Remove-Vowels-from-a-String/cpp-1119/CMakeLists.txt new file mode 100644 index 00000000..3c6ea462 --- /dev/null +++ b/1119-Remove-Vowels-from-a-String/cpp-1119/CMakeLists.txt @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.14) +project(B) + +set(CMAKE_CXX_STANDARD 14) + +add_executable(B main.cpp) \ No newline at end of file diff --git a/1119-Remove-Vowels-from-a-String/cpp-1119/main.cpp b/1119-Remove-Vowels-from-a-String/cpp-1119/main.cpp new file mode 100644 index 00000000..53d47545 --- /dev/null +++ b/1119-Remove-Vowels-from-a-String/cpp-1119/main.cpp @@ -0,0 +1,31 @@ +/// Source : https://leetcode.com/problems/remove-vowels-from-a-string/ +/// Author : liuyubobobo +/// Time : 2019-07-13 + +#include +#include + +using namespace std; + + +/// Linear Scan +/// Time Complexity: O(n) +/// Space Complexity: O(1) +class Solution { +public: + string removeVowels(string S) { + + unordered_set vowels = {'a', 'e', 'i', 'o', 'u'}; + string res = ""; + for(char c: S) + if(!vowels.count(c)) + res += c; + return res; + } +}; + + +int main() { + + return 0; +} \ No newline at end of file diff --git a/readme.md b/readme.md index c98906d1..0fe29c1c 100644 --- a/readme.md +++ b/readme.md @@ -763,4 +763,5 @@ email: [liuyubobobo@gmail.com](mailto:liuyubobobo@gmail.com) | 1111 | [Maximum Nesting Depth of Two Valid Parentheses Strings](https://leetcode.com/problems/maximum-nesting-depth-of-two-valid-parentheses-strings/) | [无] | [C++](1111-Maximum-Nesting-Depth-of-Two-Valid-Parentheses-Strings/cpp-1111/) | | | | | | | | | | | 1118 | [Number of Days in a Month](https://leetcode.com/problems/number-of-days-in-a-month/) | [无] | [C++](1118-Number-of-Days-in-a-Month/cpp-1118/) | | | -| | | | | | | +| 1119 | [Remove Vowels from a String](https://leetcode.com/problems/remove-vowels-from-a-string/) | [无] | [C++](1119-Remove-Vowels-from-a-String/cpp-1119/) | | | +| | | | | | | \ No newline at end of file