Skip to content

Commit dbc17d1

Browse files
committed
fix: resolve the reviwer comments
1 parent 73b83b2 commit dbc17d1

6 files changed

Lines changed: 13 additions & 14 deletions

File tree

Sprint-1/JavaScript/findCommonItems/findCommonItems.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
/**
22
* Finds common items between two arrays.
33
*
4-
* Time Complexity:O(1)
5-
* Space Complexity:O(n+m)
6-
* Optimal Time Complexity:O(1)
4+
* Time Complexity:O(n*m)
5+
* Space Complexity:O(u)
6+
* Optimal Time Complexity:O(n+m)
77
*
88
* @param {Array} firstArray - First array to compare
99
* @param {Array} secondArray - Second array to compare
1010
* @returns {Array} Array containing unique common items
1111
*/
1212
export const findCommonItems = (firstArray, secondArray) => {
13-
const secondArr = new Set(secondArray);
13+
const allowedItems = new Set(secondArray);
1414

1515
const uniqueValues = [
16-
...new Set(firstArray.filter((item) => secondArr.has(item))),
16+
...new Set(firstArray.filter((item) => allowedItems.has(item))),
1717
];
1818
return uniqueValues;
1919
};

Sprint-1/JavaScript/hasPairWithSum/hasPairWithSum.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
22
* Find if there is a pair of numbers that sum to a given target value.
33
*
4-
* Time Complexity:O(n)
5-
* Space Complexity:O(n)
4+
* Time Complexity:O(n^2)
5+
* Space Complexity:O(1)
66
* Optimal Time Complexity:O(n)
77
*
88
* @param {Array<number>} numbers - Array of numbers to search through
@@ -14,7 +14,6 @@ export function hasPairWithSum(numbers, target) {
1414

1515
for (let num of numbers) {
1616
const complement = target - num;
17-
console.log(complement);
1817
if (seen.has(complement)) {
1918
return true;
2019
}

Sprint-1/JavaScript/removeDuplicates/removeDuplicates.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Remove duplicate values from a sequence, preserving the order of the first occurrence of each value.
33
*
4-
* Time Complexity:O(n)
4+
* Time Complexity:O(n^2)
55
* Space Complexity:O(n)
66
* Optimal Time Complexity:O(n)
77
*

Sprint-1/Python/find_common_items/find_common_items.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ def find_common_items(
99
"""
1010
Find common items between two arrays.
1111
12-
Time Complexity: O(n+m)
13-
Space Complexity:O(n+m)
12+
Time Complexity: O(n^3)
13+
Space Complexity:O(u)
1414
Optimal time complexity: O(n+m)
1515
"""
1616

Sprint-1/Python/has_pair_with_sum/has_pair_with_sum.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ def has_pair_with_sum(numbers: List[Number], target_sum: Number) -> bool:
77
"""
88
Find if there is a pair of numbers that sum to a target value.
99
10-
Time Complexity:O(n)
11-
Space Complexity:O(n)
10+
Time Complexity:O(n^2)
11+
Space Complexity:O(1)
1212
Optimal time complexity:O(n)
1313
"""
1414
seen = set()

Sprint-1/Python/remove_duplicates/remove_duplicates.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def remove_duplicates(values: Sequence[ItemType]) -> List[ItemType]:
77
"""
88
Remove duplicate values from a sequence, preserving the order of the first occurrence of each value.
99
10-
Time complexity:O(n)
10+
Time complexity:O(n^2)
1111
Space complexity:O(n)
1212
Optimal time complexity:O(n)
1313
"""

0 commit comments

Comments
 (0)