Rubrik interview | Online

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2025-10-31Added By Anonymous
Source: Link

Company: Rubrik
Role: unknown
Interview Stage: Online
Location: unknown
Year: unknown

Original Post Content:

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 then be utilized.

How can we solve this problem?

Few approaches I have in my mind:
Create K blocks. Each block stores N/K values.
Each block stores indices from i x N/K to (i+1) x (N/K)
Doubly Linked List 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

Linked List -> 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?

Comments