My Straightforward 6ms Java Solutions

  • 0

    If you have any suggestion about the solution, please let me know.

    public int[] intersection(int[] nums1, int[] nums2) {
            HashSet<Integer> set = new HashSet<>();
            HashSet<Integer> set2 = new HashSet<>();
            for(int i =0;i<nums1.length;i++){
            for(int j =0;j<nums2.length;j++){
            int a [] = new int[set2.size()];
            Iterator<Integer> it = set2.iterator();
            for(int i =0;i<a.length;i++){
                a[i] =;
            return a;

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.