Go-数组去重
来源:互联网 发布:网络诈骗防范措施 编辑:程序博客网 时间:2024/04/27 20:41
package main import( "fmt" "sort") func RemoveDuplicatesAndEmpty(a []string) (ret []string){ a_len := len(a) for i:=0; i < a_len; i++{ if (i > 0 && a[i-1] == a[i]) || len(a[i])==0{ continue; } ret = append(ret, a[i]) } return} func main(){ a := []string{"hello", "", "world", "yes", "hello", "nihao", "shijie", "hello", "yes", "nihao","good"} sort.Strings(a) fmt.Println(a) fmt.Println(RemoveDuplicatesAndEmpty(a))}
0 0
- Go-数组去重
- 数组去数组重
- Go语言Slice去重
- 数组去重,json数组去重
- 数组去重
- 数组去重
- JS 数组去重
- 数组去重算法
- 数组去重
- js数组去重
- php 数组去重
- 数组去重
- 数组排序去重
- javascript数组去重
- json数组去重
- 数组去重
- php数组去重
- 数组如何去重
- Vijos1932重要的誓言题解
- 【unity填坑日记】Array[] Contains导致IOS AOT编译错误
- 百练 2723:不吉利日期
- poj2492&&hdu1829
- JNI的替代者—使用JNA访问Java外部功能接口
- Go-数组去重
- Leetcode59 Spiral Matrix II
- 基于cocos2d-x-3.2学习Box2D(一)
- 开博客记录生活中的点点滴滴!
- hadoop环境搭建
- 目标检测的图像特征提取之(一)HOG特征
- Android 实现点击按钮获取验证码 60秒后重新获取效果
- select 动态设置某一项为默认选中
- 华为面试题