Skip to content

Commit 38e928f

Browse files
Update complexity comments to show initial and optimal time complexities
1 parent 88fbf86 commit 38e928f

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

Sprint-1/JavaScript/calculateSumAndProduct/calculateSumAndProduct.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
* "product": 30 // 2 * 3 * 5
1010
* }
1111
*
12-
* Time Complexity: O(n)
12+
* Initial Time Complexity: O(n) [multiple passes]
1313
* Space Complexity: O(1)
14-
* Optimal Time Complexity: O(n)
14+
* Optimal Time Complexity: O(n) [single pass]
1515
*
1616
* @param {Array<number>} numbers - Numbers to process
1717
* @returns {Object} Object containing running total and product

Sprint-1/JavaScript/findCommonItems/findCommonItems.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/**
22
* Finds common items between two arrays.
33
*
4-
* Time Complexity: O(n + m)
4+
* Initial Time Complexity: O(n × m) [filter with includes]
55
* Space Complexity: O(n + m)
6-
* Optimal Time Complexity: O(n + m)
6+
* Optimal Time Complexity: O(n + m) [with Set]
77
*
88
* @param {Array} firstArray - First array to compare
99
* @param {Array} secondArray - Second array to compare

Sprint-1/JavaScript/hasPairWithSum/hasPairWithSum.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/**
22
* Find if there is a pair of numbers that sum to a given target value.
33
*
4-
* Time Complexity: O(n)
4+
* Initial Time Complexity: O(n²) [nested loops]
55
* Space Complexity: O(n)
6-
* Optimal Time Complexity: O(n)
6+
* Optimal Time Complexity: O(n) [with Set]
77
*
88
* @param {Array<number>} numbers - Array of numbers to search through
99
* @param {number} target - Target sum to find

Sprint-1/JavaScript/removeDuplicates/removeDuplicates.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
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+
* Initial Time Complexity: O(n²) [nested loops]
55
* Space Complexity: O(n)
6-
* Optimal Time Complexity: O(n)
6+
* Optimal Time Complexity: O(n) [with Set]
77
*
88
* @param {Array} inputSequence - Sequence to remove duplicates from
99
* @returns {Array} New sequence with duplicates removed

0 commit comments

Comments
 (0)