employer cover photo
employer logo
employer logo

Palantir Technologies

Questa è la tua azienda?

Domanda di colloquio di Palantir Technologies

Use a stack to implement a queue.

Risposte di colloquio

Anonimo

10 set 2012

/* Omitted Enqueue and other set up */ public E dequeue(Stacks) { if(s.size()==1) return s.pop() E tmp = s.pop(); E rez = popElem(s); s.push(tmp); return rez; }

Anonimo

3 gen 2015

The Roman's answer is almost good, if you remove the second copyElements call from dequeue then you get amortized O(1) time for both operations.