Mathworks Coding & Algorithms Interview Questions
Master your tech interview with our curated database of real questions from top companies.
Compute intersections for each segment
You are given n segments on a number line. Segment i is [startsAt[i], endsAt[i]] (inclusive), with 1 ≤ n ≤ 1e5 and 1 ≤ startsAt[i] ≤ endsAt[i] ≤ 1e9. ...
Find shortest path using BFS
Given an m×n grid grid where grid[r][c] = 0 represents an empty cell and 1 represents a wall, a start cell (sr, sc), and a target cell (tr, tc), you m...
Decide transform via one-to-one mapping
You are given two strings s and t of equal length over the lowercase English alphabet. In one step, you may pick any character x and replace all its o...
Maximize operations by removing target-sum pairs
Given an integer array nums and an integer T, in one operation you may remove two elements whose sum equals T. Return the maximum number of operations...
Maximize disjoint k-sum pairs
You are given an integer array nums and an integer k. In one operation you may remove two indices i < j if nums[i] + nums[j] == k; each index can be u...
Determine string transform via end-append moves
Given two strings s and t of equal length over lowercase English letters, in one move you may delete any character from s and append it to the end of ...
Implement BFS shortest paths with reconstruction
Given an unweighted graph with n vertices and m edges represented as an adjacency list, implement breadth-first search (BFS) from a source vertex s to...
Count interval intersections
Question For a list of n segments, where each segment i has start[i] and end[i], compute for every segment the count of other segments that intersect ...