【leetcode】Intersection of Two Arrays
来源:互联网 发布:php serialize json 编辑:程序博客网 时间:2024/05/30 07:14
Intersection of Two Arrays
Given two arrays, write a function to compute their intersection.
Example:
Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].
/** * @param {number[]} nums1 * @param {number[]} nums2 * @return {number[]} */var intersection = function(nums1, nums2) { var is ={}; for(var i=0;i<nums1.length;i++){ is[nums1[i]]=0; } var res=[]; for(i=0;i<nums2.length;i++){ if(typeof is[nums2[i]]!=="undefined"){ is[nums2[i]]=1; } } for(var num in is){ if(is[num]===1){ res.push(parseInt(num)); } } return res;};
0 0
- [LeetCode] Intersection of Two Arrays
- LeetCode Intersection of Two Arrays
- LeetCode:Intersection of Two Arrays
- 【leetcode】Intersection of Two Arrays
- leetcode Intersection of Two Arrays
- 【leetcode】Intersection of Two Arrays
- leetcode:Intersection of Two Arrays
- [Leetcode]Intersection of Two Arrays
- LeetCode:Intersection of Two Arrays
- LeetCode: Intersection of Two Arrays
- leetcode ----Intersection of Two Arrays
- LeetCode Intersection of Two Arrays
- [Leetcode] Intersection of Two Arrays
- LEETCODE--Intersection of Two Arrays
- LeetCode : Intersection of Two Arrays
- leetcode---Intersection of Two Arrays
- leetCode---Intersection of Two Arrays
- leetcode[Intersection of Two Arrays]
- 字符编码笔记:ASCII,Unicode和UTF-8(转)
- 左式堆
- 文本分类tf-idf地址搜藏
- 医院门诊管理系统
- OpenCV膨胀和腐蚀示例代码
- 【leetcode】Intersection of Two Arrays
- 用Python爬虫抓取煎蛋(jandan.net)无聊图和妹子图
- 设计模式学习笔记1
- 定时刷新参数
- java内存泄漏
- JAVA学习笔记三之(1)键盘录入数据
- Java中的多继承
- pp看书笔记---设计模式之禅第二版 第三章【依赖倒置原则】
- poj 3259 Wormholes spfa判断负环 解题报告