Skip to content

London | 25-SDC-July | Fatma Arslantas | Sprint 2 | Improve code with precomputing#77

Open
AFatmaa wants to merge 2 commits intoCodeYourFuture:mainfrom
AFatmaa:feat/sprint-2-improve-with-precomputing
Open

London | 25-SDC-July | Fatma Arslantas | Sprint 2 | Improve code with precomputing#77
AFatmaa wants to merge 2 commits intoCodeYourFuture:mainfrom
AFatmaa:feat/sprint-2-improve-with-precomputing

Conversation

@AFatmaa
Copy link

@AFatmaa AFatmaa commented Jan 17, 2026

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 optimised common_prefix and count_letters using Precomputing techniques.

  • Common Prefix:
    • Old: Compared every string with every other string.
    • New: I sorted the list first. Similar strings became neighbours. I only compared neighbours.
  • Count Letters:
    • Old: Scanned the huge string repeatedly for every uppercase letter.
    • New: I created a Set of all characters first. Checking if a lowercase letter exists is now instant.

Questions

I don’t have any questions, thank you!

@AFatmaa AFatmaa added 📅 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 Jan 17, 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.

How do you know your solutions are better?

@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 23, 2026
@AFatmaa
Copy link
Author

AFatmaa commented Feb 6, 2026

Hi @cjyuan,

Thank you for the feedback!

For your question, I thought my solution is better for two reasons:

First, I analysed the old version that used nested loops (loops inside loops). I tried to improve this by using Sets and Sorting so the code doesn't need to check the same things repeatedly. And second, I ran the tests locally, and the heavy tests finished in 8 seconds. The old code would take much longer or freeze with that amount of data.

Do you think this logic is right?

@AFatmaa AFatmaa added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Feb 6, 2026
@cjyuan
Copy link

cjyuan commented Feb 6, 2026

You were in the right direction. A more convincing proof would be to compare their complexity using the big-O notations.

@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. labels Feb 6, 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. 📅 Sprint 2 Assigned during Sprint 2 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants