Lintcode487-Name Deduplication-Easy

时间:2021-10-22 21:57:00

487. Name Deduplication

Given a list of names, remove the duplicate names. Two name will be treated as the same name if they are equal ignore the case.

Return a list of names without duplication, all names should be in lowercase, and keep the order in the original list.

Example

Example 1:

Input:["James", "james", "Bill Gates", "bill Gates", "Hello World", "HELLO WORLD", "Helloworld"]

Output:["james", "bill gates", "hello world", "helloworld"]

Clarification

You can assume that the name contains only uppercase and lowercase letters and spaces.

思路:

用hashmap去除重复,先把字符串转小写,调用toLowerCase方法,返回值要重新赋值给str!!

代码:

 public class Solution {
/**
* @param names: a string array
* @return: a string array
*/
public List<String> nameDeduplication(String[] names) {
List<String> result = new ArrayList<String>();
Map<String, Integer> map = new HashMap<String, Integer>();
for (String str : names) {
str = str.toLowerCase();
if (!map.containsKey(str)) {
map.put(str, 1);
result.add(str);
}
}
return result;
}
}

Lintcode487-Name Deduplication-Easy的更多相关文章

  1. 【转】Windows下使用libsvm中的grid&period;py和easy&period;py进行参数调优

    libsvm中有进行参数调优的工具grid.py和easy.py可以使用,这些工具可以帮助我们选择更好的参数,减少自己参数选优带来的烦扰. 所需工具:libsvm.gnuplot 本机环境:Windo ...

  2. Struts2 easy UI插件

    一.easy UI是类似于jQuery UI的插件库,它提供了丰富的各种常用插件:tree.datagrid... tree插件: 语法:$(selector).tree([settings]); 常 ...

  3. Easy UI常用插件使用

    一.easy UI是类似于jQuery UI的插件库,它提供了丰富的各种常用插件:tree.datagrid... tree插件: 语法:$(selector).tree([settings]); 常 ...

  4. UVA-11991 Easy Problem from Rujia Liu&quest;

    Problem E Easy Problem from Rujia Liu? Though Rujia Liu usually sets hard problems for contests (for ...

  5. CodeForces462 A&period; Appleman and Easy Task

    A. Appleman and Easy Task time limit per test 1 second memory limit per test 256 megabytes input sta ...

  6. easy ui插件

    简介: easy UI是类似于jQuery UI的插件库 注意:多脚本同时使用时,注意脚本冲突问题. 常用插件: 1.tree插件(tree插件实现动态树形菜单) 2.datagrid插件(datag ...

  7. 用TPP开启TDD的easy模式

    Test-Drived Development 测试驱动开发三步曲:写一个失败的测试用例->编写生产代码通过这个测试用例(transformation)->重构(refactor).重构是 ...

  8. Easy Sysprep更新日志-skyfree大神

    Easy Sysprep更新日志: Skyfree 发表于 2016-1-22 13:55:55 https://www.itsk.com/forum.php?mod=viewthread&t ...

  9. &lbrack;官方软件&rsqb; Easy Sysprep v4&period;3&period;29&period;602 【系统封装部署利器】(2016&period;01&period;22)--skyfree大神

    [官方软件] Easy Sysprep v4.3.29.602 [系统封装部署利器](2016.01.22) Skyfree 发表于 2016-1-22 13:55:55 https://www.it ...

  10. &lbrack;原创&rsqb; Easy SysLite V1&period;2 (2016&period;5&period;29更新,新增加WIN10支持,一个程序适配所有系统减肥)

    [原创] Easy SysLite V1.2 (2016.5.29更新,新增加WIN10支持,一个程序适配所有系统减肥) nohacks 发表于 2016-5-29 17:12:51 https:// ...

随机推荐

  1. z变换

    ---恢复内容开始--- z变换作用很大 将离散信号从时间域转到频率域 网址 ---恢复内容结束--- z变换作用很大 将离散信号从时间域转到频率域 网址 http://*.c ...

  2. sc 与net命令的区别

    windows服务操作命令有sc和net 两个命令; sc stop serviceName  sc start serviceName net stop serviceName  net start ...

  3. BootStrap2学习日记12---注册表单

    <form method="" action="" class="form-horizontal"> <frameset& ...

  4. Android studio gradle配置!!!【转】

    转自:http://www.open-open.com/lib/view/open1415793464648.html Gradle 基本概念 首先我们学习几个gradle 的脚本语法,掌握了这几个语 ...

  5. Python map多线程

    import os import PIL from multiprocessing import Pool from PIL import Image SIZE = (75,75) SAVE_DIRE ...

  6. org&period;apache&period;commons&period;io——FileUtils学习笔记

    FileUtils类的应用 1.写入一个文件: 2.从文件中读取: 3.创建一个文件夹,包括文件夹: 4.复制文件和文件夹: 5.删除文件和文件夹: 6.从URL地址中获取文件: 7.通过文件过滤器和 ...

  7. &lbrack;译&rsqb;在Linux上的提高MySQL&sol;MariaDB安全性的12条建议

    MySQL 是世界上最流行的开源数据库系统,而MariaDB(MySQL的一个分支)是世界上发展最快的开源数据库系统.安装MySQL服务器之后,它的默认配置是不安全的,保护它是一般数据库管理中的基本任 ...

  8. redis 集群搭建

    1.redis 集群 redis集群是一个无中心的分布式redis存储架构,可以在多个节点之间进行数据共享,解决了redis高可用.可扩展等问题,redis集群提供了以下两个好处 1.将数据自动切分( ...

  9. 男神女神配——alpha阶段总结

    一.需求分析 虽然公共社交网络系统能够满足大多数高校校园用户在校园网络社交的需求,但是针对校园学习.工作和文化生活等方面的支持以及学校个性化需求方面却存在不足.利用电子校务平台的数据,设计了与真实校园 ...

  10. 一次练习 发现的问题,malloc free 无效;findfirstfile失败,writefile失败的原因

    #include <windows.h> #include <stdio.h> #include <shlwapi.h> #pragma comment(lib,& ...