Skip to content

London | 26-Jul_SDC | Roman Sanaye | Sprint 1 | Analyse and Refactor Functions - #238

Open
RomanSanaye wants to merge 5 commits into
CodeYourFuture:mainfrom
RomanSanaye:analyse-and-refactor-functions
Open

RomanSanaye wants to merge 5 commits into
CodeYourFuture:mainfrom
RomanSanaye:analyse-and-refactor-functions

Conversation

@RomanSanaye

Copy link
Copy Markdown

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

Task code

CYF-1173

Changelist

Analysed and refactored the JavaScript functions in Sprint 1 to reduce their complexity, and documented the complexity before and after in each docblock:

  • calculateSumAndProduct: merged two loops into one. Still O(n) time, O(1) space.
  • findCommonItems: replaced includes inside filter with a Set lookup. Time O(n × m) to O(n + m).
  • hasPairWithSum: replaced nested loops with a Set of visited numbers. Time O(n²) to O(n).
  • removeDuplicates: replaced nested loops with [...new Set(inputSequence)]. Time O(n²) to O(n).

@RomanSanaye RomanSanaye added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Oct 11, 2026

@cjyuan cjyuan left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Analyses and code are good.

Could you ensure all code are consistently formatted?

@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 Oct 11, 2026
@RomanSanaye

Copy link
Copy Markdown
Author

Hi @cjyuan ,
Thanks for the feedback! I've updated the PR with consistent formatting across all files. Ready for another look whenever you're free!

@RomanSanaye RomanSanaye added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Oct 14, 2026

@cjyuan cjyuan left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Changes look good. Well done.

@cjyuan cjyuan added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Reviewed Volunteer to add when completing a review with trainee action still to take. labels Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants