Python3🔥🔥|leetcodeChallengeDay3 |python3 solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\nBy converting nums1 and nums2 to sets set1 and set2, we can easily find the set diffe
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\nBy converting nums1 and nums2 to sets set1 and set2, we can easily find the set differences between them\nThe resulting lists diff1 and diff2 contain the elements that are present in nums1 but not in nums2, and vice versa.\nBy creating a list of lists result with diff1 and diff2 as its elements, we can return both sets of elements as required by the problem statement.\n\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nWe can convert the input arrays nums1 and nums2 to sets set1 and set2, respectively\nWe can then find the set difference between set1 and set2 to get the elements that are in set1 but not in set2\nSimilarly, we can find the set difference between set2 and set1 to get the elements that are in set2 but not in set1\nWe can then create a list of lists result with diff1 and diff2 as its elements, and return result.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\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         set1,set2=set(nums1),set(nums2)\n         return[list(set1-set2),list(set2-set1)]\n\n#other possible answer for this problem is\nclass Solution:\n    def findDifference(self, nums1: List[int], nums2: List[int]) -> List[List[int]]:\n        set1=set(nums1)\n        set2=set(nums2)\n        res=[[],[]]\n\n        for i in set1:\n            if i not in set2:\n                res[0].append(i)\n        for i in set2:\n            if i not in set1:\n                res[1].append(i)\n        return res\n\n#other possible answer for this problem\nclass Solution:\n    def findDifference(self, nums1: List[int], nums2: List[int]) -> List[List[int]]:\n        set1,set2=set(nums1),set(nums2)\n        return[set1-set2,set2-set1]\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n        \n```
['Python3']