JPDev@programming.dev to Programmer Humor@programming.dev • 8 months agoReturns a sorted list in O(1) timeimagemessage-square4 fedilinkarrow-up180
arrow-up180imageReturns a sorted list in O(1) timeJPDev@programming.dev to Programmer Humor@programming.dev • 8 months agomessage-square4 Commentsfedilink
minus-squaremcmodknower@programming.devhexbear2·8 months agoyou can even have a case where you return the first element of the list if the list is not empty, and it will still be O(1). linkfedilink
minus-squaremurtaza64@programming.devhexbear1·8 months agoyou can make it sort the first k elements and it will still be O(1). Set k high enough and it might even be useful linkfedilink
you can even have a case where you return the first element of the list if the list is not empty, and it will still be O(1).
you can make it sort the first k elements and it will still be O(1). Set k high enough and it might even be useful