Rubrik interview | Online

Result
Ongoing
Posted
31 Oct 2025
604 reads

Summary

Designed two queues using an array of fixed size N to efficiently utilize empty spaces after elements are popped.

How it went

Got this question in Rubrik interview.

Design two queues using an array of fixed size N.

The interviewer said you can use an external data structure but the elements must be in the queue.

The problem here is that once the elements in the queue gets popped, it creates empty space which must be then utilized.

How can we solve this problem?

Few approaches I have in my mind:

Create K blocks. Each blocks store N/K values.

Each block store indices from i x N/K to (i+1) x (N/K)

Doubly Linkedlist points to the blocks

DLL tail -> always empty blocks for fast query of empty blocks

class LinkedListNode:

self.start_index

self.end_index

self.next_node = NULL

Linkedlist -> Keep track of blocks

head1 -> start for queue1

head2 -> start for queue2

tail -> to get empty block

While popping if the block gets empty it is moved to tail and the head is moved to next node using pointer

Is this alright?

Questions asked (1)

  1. 01

    Design Two Queues Using Fixed Size Array

    Data Structures & Algorithms

    Design two queues using an array of fixed size N.

    The interviewer said you can use an external data structure but the elements must be in the queue.

    The problem here is that once the elements in the queue gets popped, it creates empty space which must be then utilized.

Know someone preparing? Send it to them:WhatsAppLinkedInX

Interviewed at Rubrik recently?

Write up your rounds while you still remember the questions. It helps the next person more than you would think.

Share your experience
Discussion 0

Questions for the author, or how your own interview compared.

Join the discussion

Sign in with Google to comment or ask the author a question.

No comments yet

Be the first to share your thoughts and start the discussion!