package com.fishercoder.solutions;

import java.util.HashSet;
import java.util.Set;

/**
 * 804. Unique Morse Code Words

 International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows: "a" maps to ".-", "b" maps to "-...", "c" maps to "-.-.", and so on.

 For convenience, the full table for the 26 letters of the English alphabet is given below:

 [".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."]

 Now, given a list of words, each word can be written as a concatenation of the Morse code of each letter. For example, "cab" can be written as "-.-.-....-", (which is the concatenation "-.-." + "-..." + ".-"). We'll call such a concatenation, the transformation of a word.

 Return the number of different transformations among all words we have.

 Example:
 Input: words = ["gin", "zen", "gig", "msg"]
 Output: 2
 Explanation:
 The transformation of each word is:
 "gin" -> "--...-."
 "zen" -> "--...-."
 "gig" -> "--...--."
 "msg" -> "--...--."

 There are 2 different transformations, "--...-." and "--...--.".

 Note:
 The length of words will be at most 100.
 Each words[i] will have length in range [1, 12].
 words[i] will only consist of lowercase letters.
 */
public class _804 {
  public static class Solution1 {
    public int uniqueMorseRepresentations(String[] words) {
      String[] morseCodes =
          new String[] {".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---",
              "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-",
              ".--", "-..-", "-.--", "--.."};
      Set<String> concatenation = new HashSet<>();
      StringBuilder sb = new StringBuilder();
      for (String word : words) {
        sb.setLength(0);
        for (char c : word.toCharArray()) {
          sb.append(morseCodes[c - 'a']);
        }
        concatenation.add(sb.toString());
      }
      return concatenation.size();
    }
  }
}

@@ -82,1267 +82,8 @@
 t;%0A%0A
-/**%0A * 804. Unique Morse Code Words%0A%0A International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows: %22a%22 maps to %22.-%22, %22b%22 maps to %22-...%22, %22c%22 maps to %22-.-.%22, and so on.%0A%0A For convenience, the full table for the 26 letters of the English alphabet is given below:%0A%0A %5B%22.-%22,%22-...%22,%22-.-.%22,%22-..%22,%22.%22,%22..-.%22,%22--.%22,%22....%22,%22..%22,%22.---%22,%22-.-%22,%22.-..%22,%22--%22,%22-.%22,%22---%22,%22.--.%22,%22--.-%22,%22.-.%22,%22...%22,%22-%22,%22..-%22,%22...-%22,%22.--%22,%22-..-%22,%22-.--%22,%22--..%22%5D%0A%0A Now, given a list of words, each word can be written as a concatenation of the Morse code of each letter. For example, %22cab%22 can be written as %22-.-.-....-%22, (which is the concatenation %22-.-.%22 + %22-...%22 + %22.-%22). We'll call such a concatenation, the transformation of a word.%0A%0A Return the number of different transformations among all words we have.%0A%0A Example:%0A Input: words = %5B%22gin%22, %22zen%22, %22gig%22, %22msg%22%5D%0A Output: 2%0A Explanation:%0A The transformation of each word is:%0A %22gin%22 -%3E %22--...-.%22%0A %22zen%22 -%3E %22--...-.%22%0A %22gig%22 -%3E %22--...--.%22%0A %22msg%22 -%3E %22--...--.%22%0A%0A There are 2 different transformations, %22--...-.%22 and %22--...--.%22.%0A%0A Note:%0A The length of words will be at most 100.%0A Each words%5Bi%5D will have length in range %5B1, 12%5D.%0A words%5Bi%5D will only consist of lowercase letters.%0A */%0A
 publ
@@ -98,16 +98,18 @@
  _804 %7B%0A
+  
   public
@@ -134,16 +134,20 @@
 tion1 %7B%0A
+    
     publ
@@ -200,24 +200,30 @@
 ds) %7B%0A      
+     
+ 
 String%5B%5D mor
@@ -232,16 +232,26 @@
 Codes =%0A
+          
         
@@ -264,17 +264,16 @@
 String%5B%5D
- 
 %7B%22.-%22, %22
@@ -332,24 +332,38 @@
 .%22, %22.---%22,%0A
+              
             
@@ -462,16 +462,30 @@
         
+      
+        
 %22.--%22, %22
@@ -514,16 +514,22 @@
 ;%0A      
+   
+   
 Set%3CStri
@@ -561,24 +561,30 @@
 ashSet%3C%3E();%0A
+      
       String
@@ -619,24 +619,30 @@
 er();%0A      
+  
+    
 for (String 
@@ -665,16 +665,24 @@
         
+       
+ 
 sb.setLe
@@ -690,16 +690,24 @@
 gth(0);%0A
+        
         
@@ -752,16 +752,26 @@
         
+ 
+         
 sb.appen
@@ -806,18 +806,31 @@
     
-%7D%0A
+        %7D%0A     
         
 conc
@@ -825,16 +825,19 @@
         
+   
 concaten
@@ -868,24 +868,36 @@
 ;%0A      
-%7D%0A
+      %7D%0A  
       
+    
 return c
@@ -921,16 +921,22 @@
 ();%0A    
-%7D%0A
+    %7D%0A  
   %7D%0A%7D%0A

refactor 804