Genpact Hiring | Find the Difference of Two Arrays | HashSet | Online Assessment 2024

Question · Posted Jun 2026

Problem Statement You are given two integer arrays nums1 and nums2. Return a list answer of size 2 where: answer[0] contains all distinct integers present in nums1 but not in nums2. answer[1] contains all distinct integers present in nums2 but not in nums1. The order of elements in the returned lists does not matter. Example 1 Input nums1 = [1,2,3] nums2 = [2,4,6] Output [[1,3],[4,6]] Explanation Distinct elements in nums1 not present in nums2: [1,3] Distinct elements in nums2 not ...

The full answer & interview discussion are available to premium members.

Log in Create a free account