❤️Easy Solution in 🔥C++,🔥JAVA,🔥Python||❤️Daily Leetcode solution
Please upVote \u2764\uFE0F\n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time complexity:O(nlogn)\n Add your time complexit
# Please upVote \u2764\uFE0F\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:O(nlogn)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n```C++ []\nclass Solution {\npublic:\n    vector<vector<int>> findDifference(vector<int>& nums1, vector<int>& nums2) {\n    vector<vector<int>> ans(2);\n    set<int> st1(nums1.begin(), nums1.end());\n    set<int> st2(nums2.begin(), nums2.end());\n    set_difference(st1.begin(), st1.end(), st2.begin(), st2.end(), back_inserter(ans[0]));\n    set_difference(st2.begin(), st2.end(), st1.begin(), st1.end(), back_inserter(ans[1]));\n    return ans;\n    }\n};\n```\n```Java []\npublic class Solution {\n    public static List<List<Integer>> findDifference(List<Integer> nums1, List<Integer> nums2) {\n        List<List<Integer>> ans = new ArrayList<>(2);\n        Set<Integer> st1 = new HashSet<>(nums1);\n        Set<Integer> st2 = new HashSet<>(nums2);\n        List<Integer> temp = new ArrayList<>();\n        List<Integer> temp1 = new ArrayList<>();\n        for (int x : st1) {\n            if (!st2.contains(x)) {\n                temp.add(x);\n            }\n        }\n        for (int x : st2) {\n            if (!st1.contains(x)) {\n                temp1.add(x);\n            }\n        }\n        ans.add(temp);\n        ans.add(temp1);\n        return ans;\n    }\n}\n```\n```python []\ndef findDifference(nums1: List[int], nums2: List[int]) -> List[List[int]]:\n    ans = [[], []]\n    st1 = set(nums1)\n    st2 = set(nums2)\n    ans[0] = list(st1 - st2)\n    ans[1] = list(st2 - st1)\n    return ans\n```\n\n\n# C++ second Code\n```\nclass Solution {\npublic:\n    vector<vector<int>> findDifference(vector<int>& nums1, vector<int>& nums2) {\n        vector<vector<int>> ans;\n        set<int> st1;\n        set<int> st2;\n        for(auto x: nums1)\n        {\n            st1.insert(x);\n        }\n        for(auto x: nums2)\n        {\n            st2.insert(x);\n        }\n        vector<int> temp;\n        vector<int> temp1;\n        for(auto x:st1)\n        {\n            if(st2.find(x)==st2.end())\n            {\n                temp.push_back(x);\n            }\n        }\n        for(auto x:st2)\n        {\n            if(st1.find(x)==st1.end())\n            {\n                temp1.push_back(x);\n            }\n        }\n        ans.push_back(temp);\n        ans.push_back(temp1);\n        return ans;\n    }\n};\n```\n# c++ third code\n```\nclass Solution {\npublic:\n    vector<vector<int>> findDifference(vector<int>& nums1, vector<int>& nums2) {\n    vector<vector<int>> ans(2);\n    unordered_set<int> set1(nums1.begin(), nums1.end());\n    unordered_set<int> set2(nums2.begin(), nums2.end());\n    for (int num : set1) {\n        if (set2.find(num) == set2.end()) {\n            ans[0].push_back(num);\n        }\n    }\n    for (int num : set2) {\n        if (set1.find(num) == set1.end()) {\n            ans[1].push_back(num);\n        }\n    }\n    return ans;\n    }\n};\n```\n\n# Please upVote \u2764\uFE0F
['C++']