Commit ecbd2bf
authored
⚡️ Speed up function
Here's an optimized version of your program.
Your existing implementation uses **bubble sort**, which is O(n²). For optimal performance, you should use Python's built-in sorting, which is implemented in C and is much faster (Timsort, O(n log n)).
We keep the comments (none in your original code) and keep the function signature unchanged.
This version provides a massive speedup for all list sizes.
If you don't want to modify the input array, you could use `return sorted(arr)`, but your original bubble sort is in-place, so this preserves that behavior.sorter by 118,986%1 parent 2ed293e commit ecbd2bf
File tree
1 file changed
+7
-0
lines changed- code_to_optimize/code_directories/api_structure
1 file changed
+7
-0
lines changedLines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
0 commit comments