Commit ade741b
authored
⚡️ Speed up function
Here is an optimized version of your program.
Your original code uses a naïve bubble sort, which is highly inefficient (O(n²)).
Python has a highly optimized built-in sort, Timsort, running in O(n log n).
Replacing the manual sort with `list.sort()` (in-place sort) maintains functionality and gives a huge performance boost.
**All function signatures and return results are preserved, as are your print statements.**
This change preserves the intended output and greatly improves speed, especially for large lists.sorter by 207,897%1 parent 70360c6 commit ade741b
1 file changed
+1
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
| 3 | + | |
9 | 4 | | |
10 | 5 | | |
0 commit comments