LeetCode 350. Intersection of Two Arrays II
来源:互联网 发布:2选一数据选择器max 编辑:程序博客网 时间:2024/05/17 03:46
public class Solution { public int[] intersect(int[] nums1, int[] nums2) { if (nums1.length == 0 || nums2.length == 0) return new int[0]; Arrays.sort(nums1); Arrays.sort(nums2); List<Integer> r = new ArrayList<Integer>(); int i = 0, j = 0; while(i != nums1.length && j != nums2.length) { if (nums1[i] == nums2[j]) { r.add(nums1[i]); i++; j++; } else if (nums1[i] < nums2[j]) i++; else j++; } if (r.isEmpty()) return new int[0]; else { int[] result = new int[r.size()]; for (int h = 0; h < r.size(); h++) { result[h] = r.get(h); } return result; } }}
0 0
- LeetCode 350. Intersection of Two Arrays II
- leetcode.350. Intersection of Two Arrays II
- [leetcode] 350. Intersection of Two Arrays II
- Leetcode 350. Intersection of Two Arrays II
- leetcode 350. Intersection of Two Arrays II
- Leetcode 350. Intersection of Two Arrays II
- [leetcode] 350. Intersection of Two Arrays II
- leetcode 350. Intersection of Two Arrays II
- 【leetcode】350. Intersection of Two Arrays II
- [Leetcode] 350. Intersection of Two Arrays II
- 【leetcode】350. Intersection of Two Arrays II
- LeetCode 350. Intersection of Two Arrays II
- LeetCode - 350. Intersection of Two Arrays II
- LeetCode 350. Intersection of Two Arrays II
- leetcode 350. Intersection of Two Arrays II
- leetcode-350. Intersection of Two Arrays II
- leetcode 350. Intersection of Two Arrays II
- [leetcode]350. Intersection of Two Arrays II
- 安卓、java常用文件操作(复制,读取,写入,转换等)
- 热衷分享永远不会错
- 标准I/O
- 杂花生树(二十)
- js中&&和||
- LeetCode 350. Intersection of Two Arrays II
- Cookie和Session
- 51nod 1004 n^n的末位数字
- maven中的groupId和artifactId到底指的是什么?
- win32窗口机制之CreateWindowEX
- C语言指针的基本概念
- iOS 最新面试题
- Maven, Spring MVC, Mybatis, Mysql and Java_2
- SIP学习