Panda Guru LogoPanda
Guru

IBM - Standard General Software OA | 7/11/2024

Round 1

Questions:

  1. Array Operations: You are given an array of numbers. Next, you are given a list of operations that indicates the range of indices of the array that you are required to reverse them. You are to return the final form of the array after going through all the operations.

Eg. Array of Numbers: [0,1,2,3,4,5,6,7,8,9]
List of operations: [[0,9],[2,4],[1,3]]

1st Operation:
Array of Numbers: [9,8,7,6,5,4,3,2,1,0]

2nd Operation (Using the array of numbers that have went through the 1st operation):
Array of Numbers: [9,8,5,6,7,4,3,2,1,0]

3rd Operation (Using the array of numbers that have went through the 2nd operation):
Array of Numbers: [9,6,5,8,7,4,3,2,1,0]

Final form is [9,6,5,8,7,4,3,2,1,0].

  1. Minimizing of the highest priority: A system used by a compliance department contains a queue of all current compliance issues along with their priorities. The priorities range from 1 to 99. Create an algorithm that will reassign priorities so that the value of the maximum priority assigned is minimized, keeping the relative priorities between all issues the same.

Example
• Input: priorities = [1, 4, 8, 4]
• Output: [1, 2, 3, 2]
Explanation: There are three priority levels: 1, 4, and 8. The array elements are reassigned to priorities [1, 2, 3, 2]. Their relative priorities are maintained while the value of the maximum priority is minimized.

Task
Given the priorities of the issues, return a list that contains the reassigned priority values without reordering.
Function Description
Complete the reassignedPriorities function in the provided code. It must return an integer list that represents the reassigned priorities of each element in the original order.

Function Signature:
Java Example: public static List reassignedPriorities(List priorities)

Parameters
• List priorities: an array of integers that represents current priorities.

Constraints
• 1 ≤ n ≤ 10^5 (where n is the size of the input list)
• 1 ≤ priorities[i] ≤ 99

Candidate's Approach

No approach provided.

Interviewer's Feedback

No feedback provided.