Optiver OA: Key Questions and How to Solve Them

Optiver’s Online Assessment (OA) really tests your tech skills, logical thinking, and problem – solving. If you prepare well andsystematically, you’ll have a much better shot at acing it. Remember, it’s not just about being super skilled technically.You also need to be able to talk clearly and with confidence during the interview. Let’s get started on prepping for the Optiver OA together. We can look forward to a great result! If you need any extra help, just give us a shout. We offer all – round interview support to helpyou stand out in the Optiver OA.

Optiver OA

Optiver OA question1

Given an integer array weights, each day you need to select a number x, reduce it by floor(x/2), and keep the remaining part in the array. Repeat this process for d days and find the minimum possible sum of the array elements.

How to solve it?

Sort the array in descending order to easily access the largest element each day.

  • Identify the largest element in the array.
  • Halve this element using floor(x/2).
  • Place the halved value back into the array.
  • Re-sort the array in descending order to prepare for the next iteration.

Calculate the sum of the array after completing all d operations.

def minimize_array_sum(weights, d):
    # Sort the array in descending order
    weights.sort(reverse=True)

    for _ in range(d):
        # Get the maximum value from the array
        max_val = weights[0]
        # Reduce the maximum value by half
        reduced_val = max_val // 2
        # Place the reduced value back into the array
        weights[0] = reduced_val
        # Re-sort the array in descending order
        weights.sort(reverse=True)

    # Calculate and return the sum of the array
    return sum(weights)

# Example usage
weights = [4, 8, 16]
d = 3
print(minimize_array_sum(weights, d)) # Output: 12

Optiver OA question2

Given an integer array videoChunks, partition it into k consecutive subarrays such that the total cost of all subarrays is minimized. Specifically, the cost of each subarray is determined by the sum of its firstand last elements.

What are the steps to solve it?

  1. Define dp[i][j] as the minimum cost to partition the first i elements of the array into j subarrays.
  2. For each i, j, iterate over a split point m from j-1 to i-1, combining the cost dp[m][j-1] with the cost of the last subarray (sum of videoChunks[m+1] and videoChunks[i]).
  3. Take the minimum over all possible m.
def min_cost_partition(videoChunks, k):
    n = len(videoChunks)
    if k >= n:
        return sum(videoChunks) * 2 # Each element is its own subarray

    # Initialize DP table
    dp = [[float('inf')] * (k + 1) for _ in range(n)]

    # Base case: one subarray
    for i in range(n):
        dp[i][1] = videoChunks[0] + videoChunks[i]

    # Fill DP table
    for j in range(2, k + 1):
        for i in range(j, n):
            for m in range(j-1, i):
                cost = dp[m][j-1] + videoChunks[m+1] + videoChunks[i]
                dp[i][j] = min(dp[i][j], cost)

    return dp[n-1][k]

# Example usage
videoChunks = [1, 3, 5, 7]
k = 2
print(min_cost_partition(videoChunks, k)) # Output: 12

The Optiver Online Assessment (OA) thoroughly evaluates technical know-how, logical reasoning, and problem-solving prowess. With methodicalpreparation, you can greatly boost your chances of success. Remember, success isn’t just for the most technically skilled; it’s also for those who communicate well and exude confidence during the interview.

Let’s start preparing for the Optiver OA together and look forward to a great outcome. If you need more help, reach out to us. We offer full-fledged interview support to help you stand out in the Optiver OA.

author avatar
azn7u2@gmail.com
END
 0
Comment(尚無留言)