This is a verified interview question from Rubrik. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Server Queue Challenge - Rubrik Online Assessment" covers key patterns like Other.
"### Problem Alice is a system administrator managing a critical server farm. There are n pending tasks in the execution queue, task1, task2, ..., taskn from highest to lowest priority. Currently, Alice's urgent job is at the very end of the queue (lowest priority). Each task i has a complexity rating of ai. Alice needs to move her job to the front of the queue (highest priority) to ensure it executes first. Alice can perform the following operations any number of times: 1. Priority Boost: If a task is immediately ahead of Alice's job in the queue, she can move her job ahead of task i by paying a processing credits. This places her job directly behind task i-1 (if i > 1). 2. Task Reordering: Using administrative privileges, Alice can swap the positions of any two tasks i and j (where 1 ≤ i ≤ n) at a cost of (|i-j|) processing credits. Alice wants to determine the minimum total cost (processing credits) required to move her job to the front of the entire queue. You need to calculate the answer for the complete task array [a. a2, ..., an]. ### Input - t: The number of test cases - n: The number of tasks - a: The complexity ratings of tasks ### Output - The minimum total cost required to move Alice's job to the front of the queue Note: Input and Output may be incorrect"
Join thousands of developers practicing for Rubrik.