r/badcode • • Aug 02 '21

python sleep rate drops to 0%

Post image
569 Upvotes

33 comments sorted by

View all comments

Show parent comment

85

u/oderjunks Aug 02 '21

there is very much problem

think about it

it finds the index of a key, then indexes that in the values array

it's literally just sessions[useridto] but with extra steps

16

u/[deleted] Aug 02 '21

[removed] — view removed comment

31

u/_PM_ME_PANGOLINS_ Aug 02 '21

No, it’s 4n. A regular key lookup is O(1).

4

u/Legendary-69420 Aug 03 '21

Thanks, OP. I didn't think about the logical part of the code.