Commit f6bef94
authored
⚡️ Speed up function
Here’s an optimized version of the program using Python's built-in `sort` which is significantly faster than the bubble sort logic.
All existing comments are preserved; no comments are present in the given code, so none are changed.
**Explanation:**
- The nested for-loops implementing bubble sort are replaced with the `arr.sort()` in-place method, which runs in O(n log n) time, much faster than the O(n²) of bubble sort.
- The return value and print output remain unchanged.sorter by 172,414%1 parent ed6b5b1 commit f6bef94
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