unique(未完成)
const unique = arr => {
const sortedArr = arr.sort((a, b) => a > b);
const first = sortedArr[0];
let last = sortedArr[sortedArr.length - 1];
const result = [];
result.push(last);
for(let len = sortedArr.length, i = len - 2; i > 0; i--) {
const temp = sortedArr[i];
if(last === temp) {
continue;
} else {
if(last > temp) {
result.push(temp);
if(first === temp) {
break;
} else {
last = temp;
}
}
}
}
return result;
}
unique(未完成)的更多相关文章
- [占位-未完成]scikit-learn一般实例之十一:异构数据源的特征联合
[占位-未完成]scikit-learn一般实例之十一:异构数据源的特征联合 Datasets can often contain components of that require differe ...
- [占位-未完成]scikit-learn一般实例之十:核岭回归和SVR的比较
[占位-未完成]scikit-learn一般实例之十:核岭回归和SVR的比较
- [LeetCode] Unique Substrings in Wraparound String 封装字符串中的独特子字符串
Consider the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz" ...
- [LeetCode] Minimum Unique Word Abbreviation 最短的独一无二的单词缩写
A string such as "word" contains the following abbreviations: ["word", "1or ...
- [LeetCode] Count Numbers with Unique Digits 计算各位不相同的数字个数
Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Examp ...
- [LeetCode] Unique Word Abbreviation 独特的单词缩写
An abbreviation of a word follows the form <first letter><number><last letter>. Be ...
- [LeetCode] Unique Binary Search Trees 独一无二的二叉搜索树
Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For examp ...
- [LeetCode] Unique Binary Search Trees II 独一无二的二叉搜索树之二
Given n, generate all structurally unique BST's (binary search trees) that store values 1...n. For e ...
- [LeetCode] Unique Paths II 不同的路径之二
Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How m ...
随机推荐
- You Only Look Once: Unified, Real-Time Object Detection
论文下载:http://arxiv.org/abs/1506.02640 代码下载:https://github.com/pjreddie/darknet Abstract 作者提出一种新的目标检测 ...
- 203. 阿里jetcache
[视频&交流平台] àSpringBoot视频:http://t.cn/R3QepWG à SpringCloud视频:http://t.cn/R3QeRZc à Spring Boot源码: ...
- 200. Spring Boot JNDI:在Tomcat中怎么玩JNDI?
[视频&交流平台] àSpringBoot视频:http://t.cn/R3QepWG à SpringCloud视频:http://t.cn/R3QeRZc à Spring Boot源 ...
- Source Code Pro 编程字体
Source Code Pro :是 Adobe 公司号称最佳的编程字体,而且还是开源的 它非常适合用于阅读代码,支持 Linux.Mac OS X 和 Windows 等操作系统,而且无论商业或个人 ...
- !学习笔记:前端测试 、前端调试、console 等
http://www.cnblogs.com/rubekid/p/4851988.html 你真的了解 console 吗 2014 http://www.codeceo.com/article/ja ...
- leetcode124
class Solution { int maxValue; public int maxPathSum(TreeNode root) { maxValue = Integer.MIN_VALUE; ...
- python练习题_02
#1.有两个列表 l1=[11,22,33] l2=[22,33,44] #a.获取内容相同的元素列表 l3=[] for i in l1: if i in l2: l3.append(i) prin ...
- Node.js 程序应用
在打开cmd 控制台 输入 node 然后在cmd中 输入您想要的代码 加减乘除 算法.
- selenium 3.0变化
Selenium3.0的变化 最大的变化应该是去掉了Selenium RC 了,这是必然的结果.Selenium RC 是Selenium1.0的产物,Selenium2.0以WebDriver为主, ...
- 2D射影空间,为何引入射影空间
2D欧氏空间R2中,点的表示是A(x1,y1), B(x2,y2),二维参数,线的表示是L: y=kx+b,是二维参数: 如何表示点在线上面?可以扩展为(k,-1,b)* (x1,y1,1)t = 0 ...