Skip to content

WestMidlands| SDC NOV 2025 | Sara Tahir | Sprint 2 |Improve with precomputing#120

Open
SaraTahir28 wants to merge 3 commits intoCodeYourFuture:mainfrom
SaraTahir28:feature/improvewithPrecomputing
Open

WestMidlands| SDC NOV 2025 | Sara Tahir | Sprint 2 |Improve with precomputing#120
SaraTahir28 wants to merge 3 commits intoCodeYourFuture:mainfrom
SaraTahir28:feature/improvewithPrecomputing

Conversation

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

Common prefixes
In the original implementation we compared every pair of strings, which is O(n²). By sorting the list first, strings with similar prefixes become adjacent, so we only need to compare neighbouring pairs. This reduces the complexity to O(n log n)

Count Letters
I have Precomputed lowercase and uppercase character sets to avoid repeated full‑string scans.
This reduces count_letters from O(n²) to O(n).

Questions

I have no Questions. Thankyou.

@SaraTahir28 SaraTahir28 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Feb 23, 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 use complexity to explain why your implementations are better than the originals?

Copy link

Choose a reason for hiding this comment

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

The indentation and spacing of the code in this file is a bit off. Can you improve the formatting of the code?

Copy link
Author

Choose a reason for hiding this comment

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

Thankyou for you suggestion, I have addressed this in a seperate commit.

@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 26, 2026
@SaraTahir28
Copy link
Author

Can you use complexity to explain why your implementations are better than the originals?

In the original implementation we compared every pair of strings, which is O(n²). By sorting the list first, strings with similar prefixes become adjacent, so we only need to compare neighbouring pairs. This reduces the complexity to O(n log n)

Count Letters
I have Precomputed lowercase and uppercase character sets to avoid repeated full‑string scans.
This reduces count_letters from O(n²) to O(n).

@cjyuan
Copy link

cjyuan commented Feb 27, 2026

Changes and analysis are good! Well done.

@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 Feb 27, 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