方法一.ArrayList中提供的removeAll方法(效率最低) List1.removeAll(mSubList); 方法二.双重循环(比方法一效率高) 双重循环分为内外两层循环,经过测试,将元素多的list放在外层循环效率更高(mSubList中的元素可能比List1多)(被删除元素的列表List1放在外层循环和内层循环的实现方式有些差别),这里的测试数据是List1中的元素多,实现如下: int maxSize = List1.size(); for (int i = maxSize-
Problem: Given two arrays, write a function to compute their intersection. 中文:已知两个数组,写一个函数来计算它们的交集 Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2],return [2, 2]. 已知nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2]. Note: Each element in the res
题目: There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). 题意: 两个排序后的数组nums1 和nums2,长度分别是m,n,找出其中位数,并且时间复杂度:O(log(m+n)) 最愚蠢的方法: 两个数组合