ScriptOJ-unique#89
一般做法
const unique = (arr) => {
const result = arr.reduce((acc, iter) => {
if(acc.indexOf(iter) === -1) {
acc.push(iter)
}
return acc
}, [])
return result
}
超前做法
const unique = (arr) => {
return [...new Set(arr)]
}
ScriptOJ-unique#89的更多相关文章
- 初学Python常见异常错误,总有一处你会遇到!
初学Python常见错误 忘记写冒号 误用= 错误 缩紧 变量没有定义 中英文输入法导致的错误 不同数据类型的拼接 索引位置问题 使用字典中不存在的键 忘了括号 漏传参数 缺失依赖库 使用了pytho ...
- poj 1679 The Unique MST
题目连接 http://poj.org/problem?id=1679 The Unique MST Description Given a connected undirected graph, t ...
- POJ 1679 The Unique MST 【判断最小生成树是否唯一】
Description Given a connected undirected graph, tell if its minimum spanning tree is unique. Defini ...
- Mysql的唯一性索引unique
目录 唯一性索引unique影响: unique与primary key的区别: 存在唯一键冲突时,避免策略: insert ignore: replace into: insert on dupli ...
- 【二叉查找树】02不同的二叉查找树个数II【Unique Binary Search Trees II】
提到二叉查找树,就得想到二叉查找树的递归定义, 左子树的节点值都小于根节点,右子树的节点值都大于根节点. +++++++++++++++++++++++++++++++++++++++++++++++ ...
- django.core.exceptions.ImproperlyConfigured: Application labels aren't unique, duplicates: admin
创建了一个Django项目,且包含一个admin的app,但是在启动Django的是时候抛出了以下异常: Unhandled exception in thread started by <fu ...
- [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 ...
随机推荐
- spring梳理
- [Unity算法]点是否在多边形范围内
参考链接: https://www.zhihu.com/question/26551754 http://www.cnblogs.com/leoin2012/p/6425089.html 原理如下: ...
- 杰克.多西 twitter创始人 必做清单和不必做清单
必做清单 活在当下 接受脆弱(Be vulnerable) 只喝柠檬水和红酒 每天 6 组下蹲和俯卧撑 每天跑步 3 英里 每天思考本清单 站直了 打拳击沙袋 10 分钟 跟所有人打招呼 每天 7 小 ...
- Django模板语言相关内容 Djan
Django模板语言相关内容 Django模板系统 官方文档 常用语法 只需要记两种特殊符号: {{ }}和 {% %} 变量相关的用{{}},逻辑相关的用{%%}. 变量 {{ 变量名 }} ...
- ORM的相关操作
http://www.cnblogs.com/liwenzhou/p/8660826.html
- Selenium + Chrome headless 报ERROR:gpu_process_transport_factory.cc(1007)] Lost UI shared context 可忽略并配置不输出日志
Selenium不再推荐使用PhantomJS,会报如下警告 UserWarning: Selenium support for PhantomJS has been deprecated, plea ...
- vue 时间过滤
1.过滤13位时间戳(以评论时间为例) filters : { formattime2: function (value) { //value为13位的时间戳 var timestamp = Date ...
- SSM框架整合的其它方式
---------------------siwuxie095 SSM 框架整合的其它方式 1.主要是整合 Spring ...
- 【python原理解析】gc原理初步解析
python的gc是会用到:引用计数.标记-清除和分代收集,首先说明一下什么是引用计数 可以通过sys模块中的getrefcount()方法获取某个对象的引用计数 python本身的数据类型有基础类型 ...
- easyui combobox下拉框文字超出宽度有横向滚轮
//下拉框显示横向滚轮 $(".combo").mouseenter(function(){ $(this).prev().combobox("showPanel&quo ...