Skip to content

Commit

Permalink
Merge pull request neetcode-gh#2697 from AHTHneeuhl/2215
Browse files Browse the repository at this point in the history
  • Loading branch information
aakhtar3 committed Jul 13, 2023
2 parents 8439788 + 45730c3 commit 2a812b2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions cpp/2215-find-the-difference-of-two-arrays.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Time Complexity: O(n), where n is the maximum length between nums1 and nums2.
// Space Complexity: O(m), where m is the length of the resulting difference vectors.
// Time Complexity: O(m + n), we check each element of nums1Set and nums2Set
// Space Complexity: O(m + n), where m and n are length sets in worst case.

class Solution
{
Expand Down
4 changes: 2 additions & 2 deletions javascript/2215-find-the-difference-of-two-arrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* @return {number[][]}
*/

// Time Complexity: O(n), where n is the maximum length between nums1 and nums2.
// Space Complexity: O(m), where m is the length of the resulting difference lists.
// Time Complexity: O(m + n), we check each element of nums1Set and nums2Set
// Space Complexity: O(m + n), where m and n are length sets in worst case.

var findDifference = function (nums1, nums2) {
const nums1Set = new Set(nums1);
Expand Down
6 changes: 4 additions & 2 deletions python/2215-find-the-difference-of-two-arrays.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Time Complexity: O(n), where n is the maximum length between nums1 and nums2.
# Space Complexity: O(m), where m is the length of the resulting difference lists.
# Time Complexity: O(m + n), we check each element of nums1Set and nums2Set
# Space Complexity: O(m + n), where m and n are length sets in worst case.

from typing import List # ignore this, just for typing

Expand All @@ -8,6 +8,8 @@ class Solution:
def findDifference(self, nums1: List[int], nums2: List[int]) -> List[List[int]]:
nums1_set = set(nums1)
nums2_set = set(nums2)

lst1 = [num for num in nums1_set if num not in nums2_set]
lst2 = [num for num in nums2_set if num not in nums1_set]

return [lst1, lst2]
4 changes: 2 additions & 2 deletions typescript/2215-find-the-difference-of-two-arrays.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Time Complexity: O(n), where n is the maximum length between nums1 and nums2.
// Space Complexity: O(m), where m is the length of the resulting difference lists.
// Time Complexity: O(m + n), we check each element of nums1Set and nums2Set
// Space Complexity: O(m + n), where m and n are length sets in worst case.

function findDifference(nums1: number[], nums2: number[]): number[][] {
const nums1Set: Set<number> = new Set(nums1);
Expand Down

0 comments on commit 2a812b2

Please sign in to comment.