From 1bff78f6fe5625f7dc0b40182e75b191b803bc12 Mon Sep 17 00:00:00 2001 From: Lam Haoyin Date: Sun, 10 Apr 2022 00:28:44 +0800 Subject: [PATCH] add: 220410-CN [cpp] --- cpp/2204/220410-CN.cpp | 23 +++++++++++++++++++++++ cpp/2204/CMakeLists.txt | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 cpp/2204/220410-CN.cpp diff --git a/cpp/2204/220410-CN.cpp b/cpp/2204/220410-CN.cpp new file mode 100644 index 0000000..e5716a6 --- /dev/null +++ b/cpp/2204/220410-CN.cpp @@ -0,0 +1,23 @@ +#include +#include +#include + +class Solution { +private: + inline static const std::string MORSE[] = {".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."}; +public: + static int uniqueMorseRepresentations(const std::vector& words) { + std::unordered_set s; + for (const auto& str : words) { + std::string t; + for (char ch : str) + t += MORSE[ch - 'a']; + s.insert(t); + } + return s.size(); + } +}; + +int main() { + return 0; +} diff --git a/cpp/2204/CMakeLists.txt b/cpp/2204/CMakeLists.txt index 4d08d91..9de3d26 100644 --- a/cpp/2204/CMakeLists.txt +++ b/cpp/2204/CMakeLists.txt @@ -3,4 +3,4 @@ PROJECT(2204) SET(CMAKE_CXX_STANDARD 23) -ADD_EXECUTABLE(2204 220409.cpp) +ADD_EXECUTABLE(2204 220410-CN.cpp)