Skip to content

Comments

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
Nataliia74:python
Open

Glasgow | 25-SDC-Nov | Nataliia Volkova | Sprint 1 | Big-O notation and refactoring in Python tasks#96
Nataliia74 wants to merge 2 commits intoCodeYourFuture:mainfrom
Nataliia74:python

Conversation

@Nataliia74
Copy link

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide
    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.

@Nataliia74 Nataliia74 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Feb 10, 2026
Copy link

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is k?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello CJ Yuan, fixed experimental mistake.

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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implementation is not yet O(n+m).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, my bad. I changed it a little bit.

differ = target_sum - num
if differ in set_1:
return True
result.append(differ)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the use of result?

Comment on lines +24 to +27
for num in numbers:
differ = target_sum - num
if differ in set_1:
return True
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Feb 19, 2026
@cjyuan
Copy link

cjyuan commented Feb 21, 2026

The validation bot is expecting one PR for the complexity module.
It seems #95 and this PR are duplicates. Can you combine the changes into one PR and close one of them?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reviewed Volunteer to add when completing a review with trainee action still to take.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants