Judge

1. 循环list中的所有元素然后删除重复

[java] view plaincopy

  1. public   static   List  removeDuplicate(List list)  {
  2. for  ( int  i  =   0 ; i  <  list.size()  -   1 ; i ++ )  {
  3. for  ( int  j  =  list.size()  -   1 ; j  >  i; j -- )  {
  4. if  (list.get(j).equals(list.get(i)))  {
  5. list.remove(j);
  6. }
  7. }
  8. }
  9. return list;
  10. }

2. 通过HashSet踢除重复元素

[c-sharp] view plaincopy

  1. public   static   List  removeDuplicate(List list)  {
  2. HashSet h  =   new  HashSet(list);
  3. list.clear();
  4. list.addAll(h);
  5. return list;
  6. }

在groovy中当然也可以使用上面的两种方法, 但groovy自己提供了unique方法来去除重复数据

[c-sharp] view plaincopy

  1. def list = [1, 2, 3, 2, 4, 1, 5]
  2. list.unique()  // [1, 2, 3, 4, 5]
时间: 2024-10-06 06:10:09

Judge的相关文章

657. Judge Route Circle 判断线路成圆

Initially, there is a Robot at position (0, 0). Given a sequence of its moves, judge if this robot makes a circle, which means it moves back to the original place. The move sequence is represented by a string. And each move is represent by a characte

Special Judge Ⅱ

Problem Description Q:什么是 Special Judge,Special Judge 的题目有什么不同? A:一个题目可以接受多种正确答案,即有多组解的时候,题目就必须被 Special Judge.Special Judge 程序使用输入数据和一些其他信息来判答程序的输出,并将判答结果返回. NaYe 最近遇到了一个题,要求输出三个数,第三个数为前两个数的和,三个数都是素数,且前两个数小于 500000.他只需要输出任意一组符合要求的答案即认为是 Accepted.现在需

专题一、简单搜索 - Virtual Judge

很久以前刷完了Virtual Judge上的简单搜索专题,现总结如下: POJ 1321 由于题目的数据范围比较小,可以直接dfs暴力.读入时记录每个空位的位置,保存在pX[]以及pY[]数组中.暴力的时候统计当前处理第几个空格以及当前处理到了第几行即可. #include <iostream> #include <memory.h> using namespace std; const int MAX = 128; long long ans; int N, K, nCnt; b

HDOJ 2769 Disgruntled Judge 扩展GCD

扩展GCD: 枚举a,扩展GCD求b,再暴力检查 Disgruntled Judge Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 329    Accepted Submission(s): 142 Problem Description Once upon a time, there was an nwerc judge with

HDU1073 Online Judge

Online Judge Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 5373    Accepted Submission(s): 2054 Problem Description Ignatius is building an Online Judge, now he has worked out all the problem

最小生成树-并查集-Kruskal-zoj-2048-special judge

Highways description The island nation of Flatopia is perfectly flat. Unfortunately, Flatopia has a very poor system of public highways. The Flatopian government is aware of this problem and has already constructed a number of highways connecting som

Online Judge(字符串-格式)

Online Judge Problem Description Ignatius is building an Online Judge, now he has worked out all the problems except the Judge System. The system has to read data from correct output file and user's result file, then the system compare the two files.

Online Judge for ACM-ICPC etc.

原文链接:http://blog.csdn.net/tigerisland45/article/details/52134189 Virtual Judge ACM-ICPC Live Archive - Home UVa Online Judge - Home Welcome To PKU JudgeOnline(POJ) Welcome to Hangzhou Dianzi University Online Judge(HDU) OpenJudge - 百练 - 首页(PKU) Codef

关于开源OJ_在线评测系统(Online Judge)设计与实现的研究与分析

OJ是Online Judge系统的简称,用来在线检测程序源代码的正确性.著名的OJ有TYVJ.RQNOJ.URAL等.国内著名的题库有北京大学题库.浙江大学题库.电子科技大学题库.杭州电子科技大学等.国外的题库包括乌拉尔大学.瓦拉杜利德大学题库等. Online Judge系统最初使用于ACM-ICPC国际大学生程序设计竞赛和OI信息学奥林匹克竞赛中的自动判题和排名.现广泛应用于世界各地高校学生程序设计的训练.参赛队员的训练和选拔.各种程序设计竞赛以及数据结构和算法的学习和作业的自动提交判断中

Sicily Online Judge 1153.马的周游问题

1153. 马的周游问题 Constraints Time Limit: 1 secs, Memory Limit: 32 MB , Special Judge Description 和题目C同样的任务,这里只是把棋盘扩大到标准的国际象棋.对这样一个8 * 8的棋盘用同样的方法编号如下: 1     2     3       4     5     6       7     8 9     10       11    12       13    14       15    16 17