Judge
1. 循环list中的所有元素然后删除重复
- public static List removeDuplicate(List list) {
- for ( int i = 0 ; i < list.size() - 1 ; i ++ ) {
- for ( int j = list.size() - 1 ; j > i; j -- ) {
- if (list.get(j).equals(list.get(i))) {
- list.remove(j);
- }
- }
- }
- return list;
- }
2. 通过HashSet踢除重复元素
- public static List removeDuplicate(List list) {
- HashSet h = new HashSet(list);
- list.clear();
- list.addAll(h);
- return list;
- }
在groovy中当然也可以使用上面的两种方法, 但groovy自己提供了unique方法来去除重复数据
- def list = [1, 2, 3, 2, 4, 1, 5]
- list.unique() // [1, 2, 3, 4, 5]
Judge的更多相关文章
- Gym 101102C---Bored Judge(区间最大值)
题目链接 http://codeforces.com/gym/101102/problem/C problem description Judge Bahosain was bored at ACM ...
- NOJ 1074 Hey Judge(DFS回溯)
Problem 1074: Hey Judge Time Limits: 1000 MS Memory Limits: 65536 KB 64-bit interger IO format: ...
- 【教程】如何正确的写一个Lemon/Cena的SPJ(special judge)
转自:http://www.cnblogs.com/chouti/p/5752819.html Special Judge:当正确的输出结果不唯一的时候需要的自定义校验器 首先有个框架 #includ ...
- 九度 Online Judge 之《剑指 Offer》一书相关题目解答
前段时间准备华为机试,正好之前看了一遍<剑指 Offer>,就在九度 Online Judge 上刷了书中的题目,使用的语言为 C++:只有3题没做,其他的都做了. 正如 Linus To ...
- UVa Online Judge 工具網站
UVa Online Judge 工具網站 UVa中译题uHuntAlgorithmist Lucky貓的ACM園地,Lucky貓的 ACM 中譯題目 Mirror UVa Online Judg ...
- [swustoj 1021] Submissions of online judge
Submissions of online judge(1021) 问题描述 An online judge is a system to test programs in programming c ...
- HDOJ/HDU 1073 Online Judge(字符串处理~)
Problem Description Ignatius is building an Online Judge, now he has worked out all the problems exc ...
- write a macro to judge big endian or little endian
Big endian means the most significant byte stores first in memory. int a=0x01020304, if the cpu is b ...
- UVA 489-- Hangman Judge(暴力串处理)
Hangman Judge In ``Hangman Judge,'' you are to write a program that judges a series of Hangman gam ...
- 杭州电子科技大学Online Judge 之 “确定比赛名次(ID1285)”解题报告
杭州电子科技大学Online Judge 之 "确定比赛名次(ID1285)"解题报告 巧若拙(欢迎转载,但请注明出处:http://blog.csdn.net/qiaoruozh ...
随机推荐
- Android开发之MediaPlayer和SurfaceView组成视频播放器
SurfaceView 使用双缓冲技术 是个重量级的组件 只要不可见,就不会创建,可见时,才会创建 只要不可见,就会销毁 SurfaceView一旦不可见,就会被销毁,一旦可见,就会被创建,销毁时停止 ...
- 8款必备的免费移动Web开发框架(HTML5/JS)
标签:JavaScript HTML5 移动开发 Web开发 jQuery 应用程序框架 插件 概述:随着智能手机和平板电脑的普及,移动开发逐渐成为众多开发者追逐的潮流.拥有一款优秀的移动Web开发框 ...
- poj 1416 Shredding Company( dfs )
我的dfs真的好虚啊……,又是看的别人的博客做的 题目== 题目:http://poj.org/problem?id=1416 题意:给你两个数n,m;n表示最大数,m则是需要切割的数. 切割m,使得 ...
- hibernate实体的几种状态:
hibernate实体的几种状态: 实体的生命周期中,实体主要经过瞬时(Transient),托管(Attatched或Managed),游离(Detached)和销毁(Removed)四个状态. 瞬 ...
- ASP.NET Identity(处理身份数据存储) 与 OWIN主机(实现katana验证授权)原理概括
ASP.NET Identity 是4.5中引入的,支持Clamis(声明)式样登陆[即认证和授权分开模式],结合owin可以实现cookie加密等功能. 1.ASP.NET Identity架构框架 ...
- windows 7环境下配置oracle 11g 客户端
首先要去官网上下载oracle 11客户端,(我用的是64位系统)地址: http://www.oracle.com/technetwork/database/features/instant-cli ...
- 前端的小Demo——涉及keyCode
以下是我的代码: <!doctype html> <html> <head> <meta charset="utf-8"> < ...
- IE下设置unselectable与onselectstart属性的bug,Firefox与Chrome下的解决方案
在IE下给DIV设置unselectable与onselectstart属性,可以让div的内容不能选中,这个功能在很多情况下,非常有用,但是他的bug太明显, 直接使用一个DIV是可以的,比如: & ...
- InstallShield高级应用--检查是否安装ORACLE或SQL Server
InstallShield高级应用--检查是否安装ORACLE或SQL Server 实现原理:判断是否存在,是通过查找注册表是否含有相应标识来判断的. 注意:XP与WIN7系统注册表保存方式不一 ...
- DNS(三)DNS SEC(域名系统安全扩展)
工作需要今天了解了下DNS SEC,现把相关内容整理如下: 一.DNS SEC 简介 域名系统安全扩展(英语:Domain Name System Security Extensions,缩写为DNS ...