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. android 开发 View _1_ View的子类们 和 视图坐标系图

    目录: android 开发 View _2_ View的属性动画ObjectAnimator ,动画效果一览 android 开发 View _3_ View的属性动画ValueAnimator a ...

  2. Swift get和set方法以及只读属性(计算型属性,本身不保存数据,都是通过计算获得结果)

    import UIKit class Person: NSObject { private var _name: String? var name: String? { get { return _n ...

  3. 在centos上面编译安装python

    前言 因为在学习storm的过程中需要安装python,storm是部署在linux上面的,所以需要将python安装在linux上面. 安装准备 python下载 官网链接:https://www. ...

  4. 2018SDIBT_国庆个人第七场

    A - Complete the Word(暴力) Description ZS the Coder loves to read the dictionary. He thinks that a wo ...

  5. JavaScript: For , For/in , For/of

    For: define: The for statement can customize how many times you want to execute code Grammar: for (c ...

  6. Halcom学习笔记1——Halcon知识点

    文件: 1.浏览HDevelop示例程序 2.程序另存在:Ctrl+Shift+S 3.导出:Ctrl+Shift+O X 编辑: 1.快捷键:  F3 激活     F4 注销     重复查找:C ...

  7. 微擎系统jssdk系统快速签名变量

    jssdkconfig = {php echo json_encode($_W['account']['jssdkconfig']);} || { jsApiList:[] };    jssdkco ...

  8. 原子性: Interlocked 类

    public class CounterNoLock:CountBase { private int _count; public int Count { get { return _count; } ...

  9. nlp算法工程师养成记 目标要求

    时间规定: 2018.12.07-2018.02.15 能力养成: linux, shell python, c++(会多少算多少) tensorflow, keras, pytorch(tf优先) ...

  10. 算法练习LeetCode初级算法之树

    二叉树的前序遍历 我的解法:利用递归,自底向下逐步添加到list,返回最终的前序遍历list class Solution { public List<Integer> preorderT ...