add: 220410-CN [cpp]
This commit is contained in:
parent
f666f0c80e
commit
1bff78f6fe
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
@ -3,4 +3,4 @@ PROJECT(2204)
|
||||||
|
|
||||||
SET(CMAKE_CXX_STANDARD 23)
|
SET(CMAKE_CXX_STANDARD 23)
|
||||||
|
|
||||||
ADD_EXECUTABLE(2204 220409.cpp)
|
ADD_EXECUTABLE(2204 220410-CN.cpp)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue