WestMidlands| SDC NOV 2025 | Sara Tahir | Sprint 2 |Improve with precomputing#120
WestMidlands| SDC NOV 2025 | Sara Tahir | Sprint 2 |Improve with precomputing#120SaraTahir28 wants to merge 3 commits intoCodeYourFuture:mainfrom
Conversation
cjyuan
left a comment
There was a problem hiding this comment.
Can you use complexity to explain why your implementations are better than the originals?
There was a problem hiding this comment.
The indentation and spacing of the code in this file is a bit off. Can you improve the formatting of the code?
There was a problem hiding this comment.
Thankyou for you suggestion, I have addressed this in a seperate commit.
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 |
|
Changes and analysis are good! Well done. |
Learners, PR Template
Self checklist
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.