Glasgow | 25-SDC-Nov | Nataliia Volkova | Sprint 1 | Big-O notation and refactoring in Python tasks#96
Open
Nataliia74 wants to merge 2 commits intoCodeYourFuture:mainfrom
Open
Glasgow | 25-SDC-Nov | Nataliia Volkova | Sprint 1 | Big-O notation and refactoring in Python tasks#96Nataliia74 wants to merge 2 commits intoCodeYourFuture:mainfrom
Nataliia74 wants to merge 2 commits intoCodeYourFuture:mainfrom
Conversation
cjyuan
reviewed
Feb 19, 2026
cjyuan
left a comment
There was a problem hiding this comment.
Can you revert the changes made in the Sprint-1/JavaScript folder to keep the branch clean?
| Space Complexity: | ||
| Optimal time complexity: | ||
| Time Complexity: O(n+m) | ||
| Space Complexity: O(m+k) |
Comment on lines
+33
to
+39
| set_1 = set(first_sequence) | ||
| set_2 = [] | ||
|
|
||
| for seq in set_1: | ||
| if seq in second_sequence: | ||
| set_2.append(seq) | ||
| return set_2 |
| differ = target_sum - num | ||
| if differ in set_1: | ||
| return True | ||
| result.append(differ) |
Comment on lines
+24
to
+27
| for num in numbers: | ||
| differ = target_sum - num | ||
| if differ in set_1: | ||
| return True |
There was a problem hiding this comment.
This implementation is slightly different from the original implementation.
The original implementation does not allow the same element to be paired with itself. That is,
assert has_pair_with_sum([1, 4], 2) is expected to return False, but your implementation returns True.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Learners, PR Template
Self checklist
To solve these tasks I used again a hash set for constant-time lookups and processes each element once, but unlike JS logic new Set a Python set does not keep ordering, so I utilized OrderedDict.fromkeys() to create an ordered list of keys with unique items.