Repository navigation
Commit a35d066
committed
perf: optimize count_letters via pre-computed character set
- Replace O(N) string scanning with O(1) set lookup
- Transition overall algorithm complexity from O(N^2) to O(N)
- Maintain legacy loop structure and helper functions for minimal code changes
- Add documentation explaining the pre-computing strategy1 parent c8b0c59 commit a35d066
1 file changed
Lines changed: 11 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
4 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
5 | 12 | | |
| 13 | + | |
6 | 14 | | |
7 | 15 | | |
8 | | - | |
| 16 | + | |
| 17 | + | |
9 | 18 | | |
10 | 19 | | |
11 | 20 | | |
12 | 21 | | |
13 | 22 | | |
14 | | - | |
| 23 | + | |
0 commit comments