Skip to content

London| 26 March SDC | Jamal Laqdiem| Sprint 2 | Improve code with precomputing - #217

Open
jamallaqdiem wants to merge 1 commit into
CodeYourFuture:mainfrom
jamallaqdiem:improve-code-with-precomputing
Open

jamallaqdiem wants to merge 1 commit into
CodeYourFuture:mainfrom
jamallaqdiem:improve-code-with-precomputing

Conversation

@jamallaqdiem

Copy link
Copy Markdown

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

In these two exercises I optimised performance for the common_prefix and count_letters tasks by applying pre-computing strategies.

@jamallaqdiem jamallaqdiem added Module-Complexity The name of the module. 📅 Sprint 2 Assigned during Sprint 2 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Jul 15, 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.

Code is correct.

Can you use complexity to explain how the new implementation is better than the original implementation?

@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 Jul 17, 2026
@jamallaqdiem

Copy link
Copy Markdown
Author

@cjyuan thanks for reviewing my PR.
common_prefix:

Original: Used nested loops to compare every string combination. Time complexity was O(N^2 * M) (where N is the number of strings and M is string length)..
New: We sort the strings first and only compare adjacent items. Time complexity improved to O(N log N * M), which is much faster for large inputs.

count_letters:
Original: Looked up letters inside the string repeatedly, leading to extra work.
New: We do a single pass over the string to build two sets, then check for uppercase-only letters in O(1) constant time. Total time complexity is O(N).

@jamallaqdiem jamallaqdiem added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Oct 16, 2026
@github-actions

Copy link
Copy Markdown

Your PR didn't include a Task ID in its description.

Make sure you have put the correct Task ID in its description.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above.

@github-actions github-actions Bot removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Oct 16, 2026
@cjyuan

cjyuan commented Oct 16, 2026

Copy link
Copy Markdown

All good.

Note:

Original: Looked up letters inside the string repeatedly, leading to extra work.

"extra work" is ambiguous. Would be more precise to show complexity in big O notation.


Please note that starting September, the validation bot will remove the "Needs review" label from a PR if the PR description does not include a proper Task Code. You could find the task code of an exercise in the corresponding backlog/issue of the task.

@cjyuan cjyuan added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Oct 16, 2026
@github-actions

Copy link
Copy Markdown

Your PR didn't include a Task ID in its description.

Make sure you have put the correct Task ID in its description.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above.

1 similar comment
@github-actions

Copy link
Copy Markdown

Your PR didn't include a Task ID in its description.

Make sure you have put the correct Task ID in its description.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above.

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. Module-Complexity The name of the module. 📅 Sprint 2 Assigned during Sprint 2 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants