import java.util.*;
import java.lang.*;
public class Test{
public static int fun_solve(String[] words){
String[] trans_list = {".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."};
StringBuilder sBuilder = new StringBuilder(); // 用于对word进行morse翻译的存储
Set<String> words_morse_list = new HashSet<String>();//用于存放翻译好的所有word
for(String word:words){
char[] letter_list = word.toCharArray();
for(char letter:letter_list){
sBuilder.append(trans_list[letter - 'a']);
}
words_morse_list.add(sBuilder.toString());
sBuilder.replace(0, sBuilder.length(), "");
}
return words_morse_list.size();
}
public static void main(String[] args){ String[] words = {"gin", "zen", "gig", "msg"};
System.out.println(fun_solve(words)); } }

  

【leetcode】804的更多相关文章

  1. 【LeetCode】804. Unique Morse Code Words 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述: 题目大意 解题方法 set + map set + 字典 日期 题目地 ...

  2. 【Leetcode】804. Unique Morse Code Words

    Unique Morse Code Words Description International Morse Code defines a standard encoding where each ...

  3. 【LeetCode】Minimum Depth of Binary Tree 二叉树的最小深度 java

    [LeetCode]Minimum Depth of Binary Tree Given a binary tree, find its minimum depth. The minimum dept ...

  4. 【Leetcode】Pascal&#39;s Triangle II

    Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Return [1,3 ...

  5. 53. Maximum Subarray【leetcode】

    53. Maximum Subarray[leetcode] Find the contiguous subarray within an array (containing at least one ...

  6. 27. Remove Element【leetcode】

    27. Remove Element[leetcode] Given an array and a value, remove all instances of that value in place ...

  7. 【刷题】【LeetCode】007-整数反转-easy

    [刷题][LeetCode]总 用动画的形式呈现解LeetCode题目的思路 参考链接-空 007-整数反转 方法: 弹出和推入数字 & 溢出前进行检查 思路: 我们可以一次构建反转整数的一位 ...

  8. 【刷题】【LeetCode】000-十大经典排序算法

    [刷题][LeetCode]总 用动画的形式呈现解LeetCode题目的思路 参考链接 000-十大经典排序算法

  9. 【leetcode】893. Groups of Special-Equivalent Strings

    Algorithm [leetcode]893. Groups of Special-Equivalent Strings https://leetcode.com/problems/groups-o ...

随机推荐

  1. 文本(TextView)

    今天给大家介绍一下简单的文本. 首先我们看下TextView的继承关系和一些基本的属性: xml文件如下: <?xml version="1.0" encoding=&quo ...

  2. CI框架去除index.php

    打开apache的配置文件,conf/httpd.conf : LoadModule rewrite_module modules/mod_rewrite.so 把该行前的#去掉. 搜索 AllowO ...

  3. c# winfrom 皮肤切换 控件 IrisSkin2.dll 使用

    在c#应用程序中使用IrisSkin2.dll美化界面 IrisSkin2.dll 下载地址:http://d.download.csdn.net/down/1694982/sgear 一.添加控件I ...

  4. Current_Path 获取脚本所在路径(当前路径),取当前时间做文件名(uformat)

    获取脚本当前所在路径: $CurrentPath = $MyInvocation.MyCommand.Path.substring(0,$MyInvocation.MyCommand.Path.Las ...

  5. 如何实现本机Windows连接虚拟机中的CentOS

    1.确定CentOS的IP地址,命令为 ifconfig,由此可知,LinuxIP地址为 192.168.85.128 2.WIndows的IP地址为192.168.16.1, 3.保证CentOS和 ...

  6. Spark SQL on Yarn-Cluster

    Spark SQL 或者Hive SQL在yarn-client模式下运行正常,但是在yarn-cluster模式下总是报 status failed错误, 需要把$SPARK_HOME/lib/sp ...

  7. hdu 5521 Meeting(最短路)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5521 题意:有1-n共n个点,给出m个块(完全图),并知道块内各点之间互相到达花费时间均为ti.已知两 ...

  8. Java虚拟机6:垃圾收集(GC)-1(内存溢出和内存泄漏的区别)

    1.前言 在进行垃圾收集之前需要普及几个比较重要的概念. 2.内存溢出和内存泄露的概念和区别: (1):内存溢出(out of memory):是指程序在申请内存时,没有足够的内存空间可以分配,系统不 ...

  9. FP又称为Monadic Programming

    什么是Monad? trait Monad[+T] { def flatMap[U]( f : (T) => Monad[U] ) : Monad[U] def unit(value : B)  ...

  10. 【bzoj3456】 城市规划

    题目 一句话题意,无向连通图计数 技不如人,甘拜下风 设\(f_i\)表示\(i\)个节点构成的无向连通图数量 之后...之后就不会了 于是抄题解 考虑容斥 \[f_i=t_i-\sum_{j=1}^ ...