MathWorks Online Assessment

Anonymous User
164
Nov 05, 2026
Nov 05, 2026

I recently appeared for the MathWorks Online Assessment (OA). From what I observed, participants received different sets of questions, and the difficulty level varied considerably across candidates.

I found the first two problems to be in the Medium range (considering LeetCode difficulty levels), whereas the third problem was considerably more challenging. Interestingly, I later found that the third problem, or a very similar variant, had appeared in previous online assessments, interviews, and competitive programming contests, particularly on Codeforces.

Here is a brief description of the three problems I encountered:

1. Minimum Cost to Traverse a Ring

We are given an array cost, where cost[i] represents the cost of moving from element i to either of its adjacent elements (clockwise or anticlockwise).

The elements are arranged in a circular manner, meaning the first and last elements are also adjacent.

We are also given an array of requests specifying the elements we need to visit. Initially, we are positioned at element 1, and we can move either clockwise or anticlockwise.

The objective is to determine the minimum total cost required to fulfil all the requests in the given order.

Constraints:

  • Number of elements: approximately 2000.
  • Number of requests: up to 10^5.

2. Minimum Time to Schedule a Meeting

We are given an array of strings representing people's schedules. Each string follows a format similar to:

"Alex work 01:00 13:30"

This indicates that Alex is busy with work from 01:00 to 13:30 (both endpoints inclusive).

There can be multiple entries for the same person, representing different busy intervals. There can also be entries corresponding to other people.

We are additionally given an integer k, representing the required duration of the meeting.

The objective is to find the earliest possible starting time at which the meeting can be scheduled such that:

  • Everyone is available throughout the meeting.
  • The meeting duration is exactly k.
  • The meeting must start and finish on the same day.

If no valid time slot exists, return -1.

Constraints:

  • Number of schedule entries: up to 10^5.

3. Minimum Diameter of a Tree After Removing Exactly K Nodes

We are given a tree with n nodes, numbered from 0 to n-1, an integer k, and an array of edges representing the tree.

We need to minimize the diameter of the resulting tree by removing exactly k leaf nodes.

An important detail is that after removing a leaf node, its parent may become a leaf itself and can subsequently be removed. Thus, the removal process can continue iteratively.

The objective is to determine the minimum possible diameter after exactly k such removals.

Constraints:

Comments (1)