Class Solution

java.lang.Object
g2001_2100.s2032_two_out_of_three.Solution

public class Solution extends Object
2032 - Two Out of Three.<p>Easy</p> <p>Given three integer arrays <code>nums1</code>, <code>nums2</code>, and <code>nums3</code>, return <em>a <strong>distinct</strong> array containing all the values that are present in <strong>at least two</strong> out of the three arrays. You may return the values in <strong>any</strong> order</em>.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> nums1 = [1,1,3,2], nums2 = [2,3], nums3 = [3]</p> <p><strong>Output:</strong> [3,2]</p> <p><strong>Explanation:</strong> The values that are present in at least two arrays are:</p> <ul> <li> <p>3, in all three arrays.</p> </li> <li> <p>2, in nums1 and nums2.</p> </li> </ul> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> nums1 = [3,1], nums2 = [2,3], nums3 = [1,2]</p> <p><strong>Output:</strong> [2,3,1]</p> <p><strong>Explanation:</strong> The values that are present in at least two arrays are:</p> <ul> <li> <p>2, in nums2 and nums3.</p> </li> <li> <p>3, in nums1 and nums2.</p> </li> <li> <p>1, in nums1 and nums3.</p> </li> </ul> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> nums1 = [1,2,2], nums2 = [4,3,3], nums3 = [5]</p> <p><strong>Output:</strong> []</p> <p><strong>Explanation:</strong> No value is present in at least two arrays.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= nums1.length, nums2.length, nums3.length <= 100</code></li> <li><code>1 <= nums1[i], nums2[j], nums3[k] <= 100</code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • twoOutOfThree

      public List<Integer> twoOutOfThree(int[] nums1, int[] nums2, int[] nums3)