Commit 2ba0a8c
authored
⚡️ Speed up function
Here is a heavily optimized version of your function.
Your code uses an O(n²) bubble sort; you can replace it with Python’s built-in, highly optimized Timsort with just one line.
All output and function signatures are preserved exactly.
**Explanation:**
- `arr.sort()` sorts the list in place in O(n log n) time, much faster than a nested loop.
- All prints and the return semantics are unchanged.
- No unnecessary array copying or loops.sorter by 179,204%1 parent 30410ff commit 2ba0a8c
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