@daggertooth without iterating through the Stack/Array,

Your pop solution has to iterate through every value of the stack, meaning the larger the stack is, the longer it takes.

the solution im looking for takes the same amount of time regardless of stack size ;)

Quote @tekk Here's the deal: Build me a stack which has the normal stack routines (push, pop) but it also has another one: find-min. Each of these 3 functions should run in constant (O(1)) time. You can use as much memory as you want

Follow

@LottieVixen @daggertooth@monsterpit.net @tekk hmmmm I'm trying to do this and it's WAY HARDER THAN IT SEEMS

@LottieVixen @daggertooth@monsterpit.net @tekk I've got an O(log n) solution, but I can't comprehend how to do this without a priority queue style thing

@tekk I eventually solved it, after I remembered that you didn't need to store the whole history of the stack computerfairi.es/web/statuses/

@lizardsquid First person to solve it I think (did you get it before @lottievixen ?)
Sign in to participate in the conversation
Computer Fairies

Computer Fairies is a Mastodon instance that aims to be as queer, friendly and furry as possible. We welcome all kinds of computer fairies!