Solved using Set property||Efficient||Faster||Easy||Time Complexity: O(n)||Space Complexity: O(n)
Intuition\n Describe your first thoughts on how to solve this problem. \nBrute Force: For each element in the first array, check if it exists in the second arra
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nBrute Force: For each element in the first array, check if it exists in the second array. If it does not, add it to the result array. This method has a time complexity of O(n^2) and is not recommended for large arrays.\n# Approach\n<!-- Describe your approach to solving the problem. -->\nThe approach used in this solution is to first convert both input lists into sets, which have O(1) lookup time. Then, we use the set difference operator - to find the values that are in set1 but not in set2, and the values that are in set2 but not in set1. Finally, we convert the resulting sets back into lists and return them as a list of two lists.\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n    def findDifference(self, nums1: List[int], nums2: List[int]) -> List[List[int]]:\n        # Convert both lists to sets\n        set1 = set(nums1)\n        set2 = set(nums2)\n        # Get the elements that are in set1 but not in set2\n        ans1 = list(set1 - set2)\n        # Get the elements that are in set2 but not in set1\n        ans2 = list(set2 - set1)\n        # Return the results as a list of two lists\n        return [ans1, ans2]\n\n\n```
['Array', 'Math', 'Ordered Set', 'Python3']