Feature #12: Priority Validation

Implement the "Priority Validation" feature for our "Operating System" project.


The operating system assigns a priority level to every process in the system. At the start, each process is assigned a priority number of 0, which signifies the lowest priority level. The OS may increase a process priority to avoid starvation. Starvation is the problem that occurs when high-priority processes keep executing and low-priority processes are blocked for an indefinite period of time.

The priority of a process can be increased with specified increments. The first increment must always be by 1. Subsequent adjustments in priority can be made by an amount of k, k+1, or k-1 where k is the amount by which the priority was last updated. In this feature, we are given an array that represents several of a specific process’s priority levels. We need to check if some elements in the array constitute a valid priority update sequence for a real process.

We’ll be given an array of integers, priorities, and we will return true if we can reach the last priority using the aforementioned priority update We’ll be given an array of integers, false.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.