bug in logic 350. Intersection of Two Arrays II

Hi can any one please help me where I'm wrong. When I run code all cases are pass but when I submit it

Wrong Answer
Details 
Input
[1]
[1]
Output
[1,1]
Expected
[1]

my code is

class Solution {
    public int[] intersect(int[] nums1, int[] nums2) {
        
        for (int i = 0; i < nums1.length; i++) {
            for (int j = 0; j < nums2.length; j++) {     
                if (nums1.length == 0) 
                {
                    return nums1;
                }   
                if (nums2.length == 0) 
                {
                    return nums2;
                }   
                if (nums1[i] == nums2[j]) {
                    return new int[]  {nums2[i],nums2[j]};
                }
            }
        }
        return null;
    }
}
Comments (1)