Skip to content

Conversation

@RihannaP
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

Changelist

I could understand code that most of them had complexity with nested loops. I refactored them by using Set and one loops to help complexity in both JS and PY.

Questions

No question

@RihannaP RihannaP added 📅 Sprint 1 Assigned during Sprint 1 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Module-Complexity The name of the module. labels Jan 30, 2026
@LonMcGregor LonMcGregor added the Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. label Feb 11, 2026
Copy link

@LonMcGregor LonMcGregor left a comment

Choose a reason for hiding this comment

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

Good work on these, you have found some good optimisations.

There are a few times you identify nested loops as o(n). If you have a nested loop, with the same array looping each time, are you sure it is going to be o(n)?

See also my other comment, there may be better ways to use sets in javascript.

];
export const findCommonItems = (firstArray, secondArray) => {
const lookup = new Set(secondArray);
return [...new Set(firstArray.filter(item => lookup.has(item)))];

Choose a reason for hiding this comment

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

Given you are using sets, are there any built-in methods that might help make this code even simpler?

@LonMcGregor LonMcGregor 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. Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Feb 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Module-Complexity The name of the module. Reviewed Volunteer to add when completing a review with trainee action still to take. 📅 Sprint 1 Assigned during Sprint 1 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants