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(未完成)的更多相关文章

  1. [占位-未完成]scikit-learn一般实例之十一:异构数据源的特征联合

    [占位-未完成]scikit-learn一般实例之十一:异构数据源的特征联合 Datasets can often contain components of that require differe ...

  2. [占位-未完成]scikit-learn一般实例之十:核岭回归和SVR的比较

    [占位-未完成]scikit-learn一般实例之十:核岭回归和SVR的比较

  3. [LeetCode] Unique Substrings in Wraparound String 封装字符串中的独特子字符串

    Consider the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz" ...

  4. [LeetCode] Minimum Unique Word Abbreviation 最短的独一无二的单词缩写

    A string such as "word" contains the following abbreviations: ["word", "1or ...

  5. [LeetCode] Count Numbers with Unique Digits 计算各位不相同的数字个数

    Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Examp ...

  6. [LeetCode] Unique Word Abbreviation 独特的单词缩写

    An abbreviation of a word follows the form <first letter><number><last letter>. Be ...

  7. [LeetCode] Unique Binary Search Trees 独一无二的二叉搜索树

    Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For examp ...

  8. [LeetCode] Unique Binary Search Trees II 独一无二的二叉搜索树之二

    Given n, generate all structurally unique BST's (binary search trees) that store values 1...n. For e ...

  9. [LeetCode] Unique Paths II 不同的路径之二

    Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How m ...

随机推荐

  1. Variables多种表达

    Variables:TF基础数据之一,常用于变量的训练...重要性刚学TF就知道了 1.tf.Variable() tf.Variable(initial_value=None, trainable= ...

  2. c++ :

    (1)表示机构内位域的定义(即该变量占几个bit空间)   typedef struct _XXX{ unsigned char a:4; unsigned char c; } ; XXX

  3. How can I manage the modules for python2 when python3 installed as well. In OSX

    ref: https://stackoverflow.com/questions/53385448/how-can-i-manage-the-modules-for-python2-when-pyth ...

  4. 保持ssh连接长时间不断开的技巧

    我经常用ssh连接服务器,过段时间不用, 需要恢复一下断开的连接, 原因是NAT防火墙喜欢对空闲的会话进行超时处理,以确保它们状态表的干净和内存的低占用率,因为 长时间保持连接, 会长期占用部分系统资 ...

  5. jenkins Manage and Assign Roles使用

    1.安装插件  Role-based Authorization Strategy 2.使用插件 3.进入 Manage and Assign Roles  配置Pattern 匹配项目, 如果要匹配 ...

  6. redis安装--集群

    redis在3.0之后开始支持集群,实际生产中一般也是会部署集群了 redis官方推出了一个叫redis-trib.rb的redis集群工具(存放在源码文件的src目录下):由于redis-trib. ...

  7. 可以作为瘟到死(windows)路径的字符

    !#$%&""()+-0123456789;=@ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz[]^_`{}~

  8. mobilenet之Depthwise +Pointwise

    我们知道,mobilenet是适用于移动端的深度学习网络,主要优点是参数少.模型小.准确率相比一些传统卷积损失少等特点. mobileNet之所以这么ok,是因为引入了Depthwise +Point ...

  9. CDH hue下定时执行hive脚步

        今天在看oozie时发现能在hue中执行hive 脚本,主要是hue 和 oozie结合使用,下面介绍下怎么使用的,挺恶心的,哈哈(在这里就不哔哔了) 提交oozie定时作业 1.进入hue界 ...

  10. c++ 面试题(数据库)

    1,索引的原理: https://www.cnblogs.com/songwenjie/p/9414960.html https://blog.csdn.net/qq_32924343/article ...