Bloomberg interview question

Implement a queue class.

Interview Answers

Anonymous

13 Mar 2014

class ListNode { public: int val; ListNode* next; ListNode(){val=0;next=NULL;} ListNode(int v){val=v;next=NULL;} }; class Queue { public: void enqueue(int v); int dequeue(); private: ListNode* head; ListNode* tail; } void Queue::enqueue(int v){ if(head == NULL){ head = new ListNode(v); tail = head; } else{ tail->next = new ListNode(v); tail = tail->next; } } int Queue::dequeue(){ assert(head!= NULL); int ret = head->val; ListNode* temp = head; head = head->next; delete temp; return ret; }

Anonymous

5 Feb 2021

There's a lot of elements to typically cover in these questions, clarifications, scoping, making sure you're answering the actual question the interviewer is looking for you to answer, etc. Could be worth doing a mock interview with one of the Prepfully Bloomberg Financial Software Developer Intern experts... they've worked in the role so they clearly know how to get through the interview. prepfully.com/practice-interviews