GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — leetcode/java/804_Unique_Morse_Code_Words.java at master · scrz2015/leetcode Expand file tree/ Copy path804_Unique_Morse_Code_Words.javaMore file actions 19 lines (17 loc) · 734 Bytes / Copy path804_Unique_Morse_Code_Words.javaFile metadata and controls19 lines (17 loc) · 734 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 class Solution { // https://leetcode.com/problems/unique-morse-code-words/solution/ public int uniqueMorseRepresentations(String[] words) { String[] MORSE = new String[]{".-","-...","-.-.","-..",".","..-.","--.", "....","..",".---","-.-",".-..","--","-.", "---",".--.","--.-",".-.","...","-","..-", "...-",".--","-..-","-.--","--.."}; Set<String> seen = new HashSet(); for (String word: words) { StringBuilder code = new StringBuilder(); for (char c: word.toCharArray()) code.append(MORSE[c - 'a']); seen.add(code.toString()); } return seen.size(); } } |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |