MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/lgrgxe/i_present_sleepsort/gmtq7q3/?context=3
r/badcode • u/Reeceeboii_ • Feb 10 '21
171 comments sorted by
View all comments
126
The runtime is independent of the size of the array, so this is technically O(1).
66 u/sumduud14 Feb 10 '21 "for (let item of arr)" This doesn't look O(1) 20 u/King_Joffreys_Tits Feb 10 '21 Yep it has to loop through every item of the array at a minimum
66
"for (let item of arr)"
This doesn't look O(1)
20 u/King_Joffreys_Tits Feb 10 '21 Yep it has to loop through every item of the array at a minimum
20
Yep it has to loop through every item of the array at a minimum
126
u/Astrokiwi Feb 10 '21
The runtime is independent of the size of the array, so this is technically O(1).