Skip to content

Commit 2c7802c

Browse files
authored
Merge branch 'Rohit0301:master' into master
2 parents 4eab2e3 + 0307738 commit 2c7802c

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution {
2+
public:
3+
int uniqueMorseRepresentations(vector<string>& words) {
4+
set<string> ans;
5+
string morse[26] = {".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."};
6+
for (int i = 0; i < words.size(); i++) {
7+
string s;
8+
for (int j = 0; j < words[i].size(); j++) {
9+
s += morse[words[i][j] - 'a'];
10+
}
11+
ans.insert(s);
12+
}
13+
return ans.size();
14+
}
15+
};

0 commit comments

Comments
 (0)