//定义一个100元素的集合,包含A-Z List<String> list = new LinkedList<>(); for (int i =0;i<100;i++){ list.add(String.valueOf((char)('A'+Math.random()*('Z'-'A'+1)))); } System.out.println(list); //统计集合重复元素出现次数,并且去重返回hashmap Map<String, Long> map = l
利用Linux命令进行文本按行去重并按重复次数排序 linux命令行提供了非常强大的文本处理功能,组合利用linux命令能实现好多强大的功能.本文这里举例说明如何利用Linux命令行进行文本按行去重并按重复次数排序.主要用到的命令有sort,uniq.其中,sort主要功能是排序,uniq主要功能是实现相邻文本行的去重. 用于演示的测试文件内容如下: Hello World. Apple and Nokia. Hello World. I wanna buy an A
Fibonacci-ish Time Limit: 3000MS Memory Limit: 524288KB 64bit IO Format: %I64d & %I64u Submit Status Description Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if the seque
1.List<Integer>排序 List<Integer> list = new ArrayList<>();list.add(50);list.add(25);list.add(25);list.add(98);list.add(32);List<Integer> collect = list.stream().distinct().sorted().collect(Collectors.toList());System.out.println(&qu
1.背景 想要统计这一个字符串数组中每一个非重复字符串的数量,使用map来保存其key和value.这个需求在实际开发中经常使用到,我以前总是新建一个空数组来记录不重复字符串,并使用计数器计数,效率低下且麻烦,特此记录. 2.代码实现 public class test { public void makeEqual(String[] words) { Map<String,Integer> maps = new HashMap<>(); for (String str : wor
String Given a string S and two integers L and M, we consider a substring of S as “recoverable” if and only if (i) It is of length M*L; (ii) It can be constructed by concatenating M “diversified” substrings of S, where each of these substrings ha