【leetcode】804
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的更多相关文章
- 【LeetCode】804. Unique Morse Code Words 解题报告(Python)
		
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述: 题目大意 解题方法 set + map set + 字典 日期 题目地 ...
 - 【Leetcode】804. Unique Morse Code Words
		
Unique Morse Code Words Description International Morse Code defines a standard encoding where each ...
 - 【LeetCode】Minimum Depth of Binary Tree   二叉树的最小深度 java
		
[LeetCode]Minimum Depth of Binary Tree Given a binary tree, find its minimum depth. The minimum dept ...
 - 【Leetcode】Pascal's Triangle II
		
Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Return [1,3 ...
 - 53. Maximum Subarray【leetcode】
		
53. Maximum Subarray[leetcode] Find the contiguous subarray within an array (containing at least one ...
 - 27. Remove Element【leetcode】
		
27. Remove Element[leetcode] Given an array and a value, remove all instances of that value in place ...
 - 【刷题】【LeetCode】007-整数反转-easy
		
[刷题][LeetCode]总 用动画的形式呈现解LeetCode题目的思路 参考链接-空 007-整数反转 方法: 弹出和推入数字 & 溢出前进行检查 思路: 我们可以一次构建反转整数的一位 ...
 - 【刷题】【LeetCode】000-十大经典排序算法
		
[刷题][LeetCode]总 用动画的形式呈现解LeetCode题目的思路 参考链接 000-十大经典排序算法
 - 【leetcode】893. Groups of Special-Equivalent Strings
		
Algorithm [leetcode]893. Groups of Special-Equivalent Strings https://leetcode.com/problems/groups-o ...
 
随机推荐
- .net reflector+reflexil修改编译后的dll文件
			
1.用reflector打开相关的dll文件. 2.如果reflector中没有reflexil插件,点击工具栏中的Tools->Add-Ins 3.找到需要修改的文件,双击打开该文件:点击To ...
 - 解决 客户端连接  mysql5.7 Plugin 'mysql_native_plugin' is not loaded错误
			
进入mysql数据库,修改数据库的内容 1, use mysql; 2,update user set authentication_string="" where User= ...
 - 131.003 数据预处理之Dummy Variable & One-Hot Encoding
			
@(131 - Machine Learning | 机器学习) Demo 直观来说就是有多少个状态就有多少比特,而且只有一个比特为1,其他全为0的一种码制 {sex:{male, female}} ...
 - Jmeter入门(一)————线程组配置
			
线程组相当于有多个用户,同时去执行相同的一批次任务.每个线程之间都是隔离的,互不影响的.一个线程的执行过程中,操作的变量,不会影响其他线程的变量值. Delay Thread creation unt ...
 - Oracle案例09——ORA-12154: TNS:could not resolve the connect identifier specified
			
DG处理的问题还是蛮多的,但这次遇到一个比较奇葩的事情,表面配置.网络都没啥问题,但主备的同步始终有问题,经过多次调整参数.重新部署问题依旧,最终还是求助mos问题得以解决,现将处理过程记录如下: 一 ...
 - iOS设计模式 - 外观
			
iOS设计模式 - 外观 原理图 说明 1. 当客服端需要使用一个复杂的子系统(子系统之间关系错综复杂),但又不想和他们扯上关系时,我们需要单独的写出一个类来与子系统交互,隔离客户端与子系统之间的联系 ...
 - matlab 波纹扭曲
			
% 波纹扭曲 img=imread('pic.jpg'); img=im2double(img); [h,w,c]=size(img); ratio=600/(h+w); img=imresize(i ...
 - mysql DML语句学习1
			
DML 操作是指对数据库中表记录的操作,主要包括表记录插入(insert).更新(update).删除(delete)和查询(select) 1. 插入记录 表创建好后,就可以往里插入记录,基本语句如 ...
 - December 26th 2016 Week 53rd Monday
			
Better to light one candle than to curse the darkness. 与其诅咒黑暗,不如燃起蜡烛. If the world is so cruel, I wo ...
 - codeforces 932E Team Work(组合数学、dp)
			
codeforces 932E Team Work 题意 给定 \(n(1e9)\).\(k(5000)\).求 \(\Sigma_{x=1}^{n}C_n^xx^k\). 题解 解法一 官方题解 的 ...