setNums1 and add all elements of nums1 to it.setNums2 and add all elements of nums2 to it.onlyInNums1 and onlyInNums2 to store the unique elements.nums1 and for each element, check if it is not present in setNums2. If it is not, add it to onlyInNums1.nums2 and for each element, check if it is not present in setNums1. If it is not, add it to onlyInNums2.onlyInNums1 and onlyInNums2.