字符串去重(hashSet)
public static String deleteRepeat(String strn){
String s=strn;
String[] array = s.split(",");
Set<String> staffsSet = new HashSet<>(Arrays.asList(array));
String strappend="";
for (String str : staffsSet) {
strappend+=str+",";
}
String newStr = strappend.toString().substring(0,strappend.length() - 1);
return newStr;
}
字符串去重(hashSet)的更多相关文章
- 2015.4.25-2015.5.1 字符串去重,比例圆设计,中奖机和canvas橡皮擦效果等
1.字符串去重,html模板取值 2.javascript正则表达式之$1...$9 3.jquery插件 4.返回上一页并刷新 解决方法: <a href ="javas ...
- JS实现字符串去重,数组去重
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- c++ 字符串去重
##### c++ 字符串去重 == 需求 == * 编写一个字符串过滤函数,若字符串出现多个相同的字符,将不是首次出现的字符过滤掉. > 输入:"apache" 输出:&q ...
- js字符串去重
js字符串去重: 1. 去掉字符串前后所有空格: function Trim(str) { return str.replace(/(^\s*)|(\s*$)/g, ""); } ...
- js 数组&字符串 去重
Array.prototype.unique1 = function() { var n = []; //一个新的临时数组 for(var i = 0; i < this.length; i++ ...
- 面试题常考&必考之--js中的数组去重和字符串去重
1.引入:首先得知道数组没有可以直接去重的方法,即直接[].unique()是不支持的, 会报“Uncaught TypeError: [].unique is not a function”错误, ...
- c++实现哈夫曼树,哈夫曼编码,哈夫曼解码(字符串去重,并统计频率)
#include <iostream> #include <iomanip> #include <string> #include <cstdlib> ...
- C#中有关字符串去重的解决方案
今天在群里看到一个同学的面试题 题目中有一个这样的要求 //本地有个文档文件a.txt里面包含的内容分为一段字符串"abacbacde"请编写一个程序,获取文件得到对应的内容,并对 ...
- C语言对字符串去重
# include <stdio.h> # include <string.h> char * getNewChar(char * str,char * newStr); in ...
随机推荐
- 【C++】多重继承
1. 多重继承时的二义性 当使用多重继承时,如果多个父类都定义了相同名字的变量,则会出现二义性.解决方法:使用 :: 声明作用域 #include <iostream> using nam ...
- [译]lambda表达式对 SAM (单个抽象方法类)type的处理方式
在阅读Venkat Subramaniam的著作<Functional Programming in Java> 之后,方法模式和lambda完美结合让我印象深刻. 这种模式经常用作数据源 ...
- set注入
顾名思义set注入必须要有set方法. 基本类型的注入.引用类型注入.List注入.Set注入.Map注入.Properties注入 public class person { private car ...
- VisualStudio 2013开发Office插件
在VS中选择创建新项目,选择App for Office 选择mail出现的位置 Task pane The app appears in the task pane of a Microsift O ...
- Rescue The Princess
Description Several days ago, a beast caught a beautiful princess and the princess was put in prison ...
- 学习PHPCMS需要掌握的函数
路径:phpcms\libs\classes\model.class.php /** * 执行sql查询 * @param $where 查询条件[例`name`='$name'] * @param ...
- CF 915 D 拓扑排序
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; const int mod = 14285 ...
- Golang基础入门
Go语言很容易上手 第一步,在你的计算机上安装Go语言环境 首先下载对应操作系统的安装包或者源文件 Windows和Mac OSX 都有安装包,可以选择直接双击安装,很简单 Ubuntu系统可以使用 ...
- codeforces 713C C. Sonya and Problem Wihtout a Legend(dp)(将一个数组变成严格单增数组的最少步骤)
E. Sonya and Problem Wihtout a Legend time limit per test 5 seconds memory limit per test 256 megaby ...
- 17、Flask实战第17天:Flask-cookie
cookie的基本概念 在网站中,http请求是无状态的.也就是说即使第一次和服务器连接并且登录成功后,第二次请求服务器依然不能知道当前请求的是哪个用户. cookie的出现就是为了解决这个问题,第一 ...