Class Solution
java.lang.Object
g2201_2300.s2215_find_the_difference_of_two_arrays.Solution
2215 - Find the Difference of Two Arrays.<p>Easy</p>
<p>Given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code>, return <em>a list</em> <code>answer</code> <em>of size</em> <code>2</code> <em>where:</em></p>
<ul>
<li><code>answer[0]</code> <em>is a list of all <strong>distinct</strong> integers in</em> <code>nums1</code> <em>which are <strong>not</strong> present in</em> <code>nums2</code><em>.</em></li>
<li><code>answer[1]</code> <em>is a list of all <strong>distinct</strong> integers in</em> <code>nums2</code> <em>which are <strong>not</strong> present in</em> <code>nums1</code>.</li>
</ul>
<p><strong>Note</strong> that the integers in the lists may be returned in <strong>any</strong> order.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> nums1 = [1,2,3], nums2 = [2,4,6]</p>
<p><strong>Output:</strong> [[1,3],[4,6]]</p>
<p><strong>Explanation:</strong></p>
<p>For nums1, nums1[1] = 2 is present at index 0 of nums2, whereas nums1[0] = 1 and nums1[2] = 3 are not present in nums2. Therefore, answer[0] = [1,3].</p>
<p>For nums2, nums2[0] = 2 is present at index 1 of nums1, whereas nums2[1] = 4 and nums2[2] = 6 are not present in nums2. Therefore, answer[1] = [4,6].</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> nums1 = [1,2,3,3], nums2 = [1,1,2,2]</p>
<p><strong>Output:</strong> [[3],[]]</p>
<p><strong>Explanation:</strong></p>
<p>For nums1, nums1[2] and nums1[3] are not present in nums2. Since nums1[2] == nums1[3], their value is only included once and answer[0] = [3].</p>
<p>Every integer in nums2 is present in nums1. Therefore, answer[1] = [].</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= nums1.length, nums2.length <= 1000</code></li>
<li><code>-1000 <= nums1[i], nums2[i] <= 1000</code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
findDifference
-