Skip to content

Conversation

@sheetalkharab
Copy link

@sheetalkharab sheetalkharab commented Oct 14, 2025

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

Changelist

refactor code

Questions

No

@sheetalkharab sheetalkharab added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Oct 14, 2025
* Time Complexity:
* Space Complexity:
* Optimal Time Complexity:
* Time Complexity:O(2n) originall have this as using 2 separate loops
Copy link

Choose a reason for hiding this comment

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

O(n) is the same as O(2n). We ignore the constant multiplier in big-O notation.

* Time Complexity:
* Space Complexity:
* Optimal Time Complexity:
* Time Complexity:O(n+m) it build set and loop through arrays once
Copy link

Choose a reason for hiding this comment

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

What's the complexity of Array.include()?

.filter() suggests a "loop", and inside the loop .includes() is called repeatedly.

* Optimal Time Complexity:
* Time Complexity:O(n+m) it build set and loop through arrays once
* Space Complexity: store second array in set
* Optimal Time Complexity:O(m+n)
Copy link

Choose a reason for hiding this comment

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

We could also write O(max(m, n))

@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 Jan 22, 2026
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