add: 220410-CN [cpp]

This commit is contained in:
Lam Haoyin 2022-04-10 00:28:44 +08:00
parent f666f0c80e
commit 1bff78f6fe
No known key found for this signature in database
GPG Key ID: 8C089CB1A2B7544F
2 changed files with 24 additions and 1 deletions

23
cpp/2204/220410-CN.cpp Normal file
View File

@ -0,0 +1,23 @@
#include <unordered_set>
#include <string>
#include <vector>
class Solution {
private:
inline static const std::string MORSE[] = {".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."};
public:
static int uniqueMorseRepresentations(const std::vector<std::string>& words) {
std::unordered_set<std::string> 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;
}

View File

@ -3,4 +3,4 @@ PROJECT(2204)
SET(CMAKE_CXX_STANDARD 23)
ADD_EXECUTABLE(2204 220409.cpp)
ADD_EXECUTABLE(2204 220410-CN.cpp)