[LeetCode]Intersection of Two Arrays II(Java)

感觉我自己这个应该是最好的了

public class Solution {
    public int[] intersect(int[] nums1, int[] nums2) {
        List interList = new ArrayList();
        Arrays.sort(nums1);
        Arrays.sort(nums2);
        int i = 0,j = 0;
        while(inums2[j]){
                j++;
            }else{
                i++;
            }
        }
        int[] interArray = new int[interList.size()];
        Iterator it = interList.iterator();
        i=0;
        while(it.hasNext()){
            interArray[i]=(Integer)(it.next());
            i++;
        }
        return interArray;
    }
}
2016/8/26

你可能感兴趣的:(学习专用,LeetCode)