
MathWorks


20+ MathWorks Interview Questions and Answers
Q1. Minimum Jumps Problem Statement
In the city of Berland, Bob and his wife visit the ‘Arcade’ mall every Friday. The mall has shops arranged in a line, and Bob can jump between these shops using trampolines. From...read more
Q2. Arrangement Problem Statement
Determine the number of permutations of list A
= [1, 2, ..., N] such that for every index i
, either A[i]
is divisible by i
or i
is divisible by A[i]
.
Input:
The input starts with a...read more
Q3. Car Pooling Capacity Problem
You are a cab driver with a car that initially has 'C' empty seats. The car moves in a straight line towards the forward direction only. Your job is to determine if it is possible t...read more
Determine if it is possible to handle all passenger trips within the car capacity without exceeding it at any point.
Iterate through each trip and keep track of the total number of passengers in the car at each point.
Check if the total number of passengers exceeds the car capacity at any point, return 'False'. Otherwise, return 'True'.
Q4. Triplets with Given Sum Problem
Given an array or list ARR
consisting of N
integers, your task is to identify all distinct triplets within the array that sum up to a specified number K
.
Explanation:
A triplet i...read more
Q5. Write a code to merge two sorted linked list.
Code to merge two sorted linked lists.
Create a new linked list to store the merged list
Compare the first nodes of both lists and add the smaller one to the new list
Move the pointer of the list with the smaller node to the next node
Repeat until one of the lists is empty, then add the remaining nodes of the other list to the new list
Return the new merged list
Q6. Convert BST to Greater Sum Tree
Given a Binary Search Tree (BST) of integers, your task is to convert it into a greater sum tree. In the greater sum tree, each node's value should be replaced with the sum of al...read more
Convert a Binary Search Tree into a Greater Sum Tree by replacing each node's value with the sum of all nodes' values greater than the current node's value.
Traverse the BST in reverse inorder (right-root-left) to visit nodes in descending order.
Keep track of the running sum of visited nodes and update each node's value with this sum.
Recursively apply the above steps to all nodes in the BST.
Example: For the input BST [4, 1, 6, 0, 2, 5, 7], the output Greater Sum Tree will be [...read more
Q7. Longest Increasing Path in Matrix Problem Statement
Given a 2-D matrix mat
with 'N' rows and 'M' columns, where each element at position (i, j) is mat[i][j]
, determine the length of the longest increasing path ...read more
Implement Stack with Linked List
Your task is to implement a Stack data structure using a Singly Linked List.
Explanation:
Create a class named Stack
which supports the following operations, each in O(1) time:
Q9. Distance To Nearest 1 in a Binary Matrix Problem
Given a binary matrix MAT
containing only 0s and 1s of size N x M, find the distance of the nearest cell containing 1 for each cell in the matrix.
The distance i...read more
Given a binary matrix, find the distance of the nearest cell containing 1 for each cell in the matrix.
Iterate through the matrix and for each cell, find the nearest cell containing 1 using BFS or DFS.
Calculate the distance using the formula |i1 – i2| + |j1 – j2|.
Update the matrix with the distances to the nearest cell with 1.
Handle edge cases like cells already containing 1 or cells with no 1s nearby.
Ensure movements are only allowed in four directions: Up, Down, Left, and Ri...read more
Q10. K-th Ugly Ninja Problem Statement
Ninja is looking to hire 'ugly ninjas' whose numbers have all prime factors from a given list. Your task is to help him find the K-th ugly ninja.
You will be given an array PRI...read more
Find the K-th ugly ninja number using prime factors from a given list.
Generate ugly numbers using prime factors from PRIME_ARR
Keep track of the K-th ugly number
Return the K-th ugly number
Q11. Optimal Strategy for a Coin Game
You and your friend Ninjax are engaged in a strategic game involving coins. Ninjax arranges 'N' coins in a linear sequence.
The rules of the game are as follows:
1. Each coin ha...read more
Determine the maximum amount you can win in a coin game by selecting coins strategically.
Start by understanding the rules of the game and the goal of maximizing winnings.
Consider the fact that you can choose either the first or last coin in each turn.
Think about how to ensure you make the best choice at each turn to guarantee the maximum win.
Examples: For the input 4 9 5 21 7, selecting coins in the order of 9 and 21 results in a maximum win of 30.
Q12. Count Pairs Divisible by K
You are given an array ARR
and a positive integer K
. Your task is to count the total number of pairs within the array whose sum is divisible by K
.
Example:
Input:
ARR = [4, 3, 5, 1, 4...read more
Count pairs in an array whose sum is divisible by a given integer K.
Iterate through the array and calculate the remainder of each element when divided by K.
Store the remainders in a hashmap along with their frequencies.
For each remainder R, check if K - R is present in the hashmap and add the product of their frequencies to the count.
Return the total count of pairs whose sum is divisible by K.
Q15. How is HIL programming different from normal software simulation?
HIL programming involves testing software with real hardware components, while normal software simulation uses virtual components.
HIL programming requires physical hardware interfaces for testing
Normal software simulation uses virtual components to mimic real-world scenarios
HIL programming provides more accurate results due to real hardware interactions
Normal software simulation is more cost-effective and easier to set up compared to HIL programming
Q16. How can you manage to meet multiple timelines in a collaborative environment ?
I prioritize tasks, communicate effectively, delegate when necessary, and use project management tools to track progress.
Prioritize tasks based on deadlines and importance
Communicate regularly with team members to ensure everyone is on track
Delegate tasks when necessary to ensure all deadlines are met
Utilize project management tools like Trello or Asana to track progress and deadlines
Q19. What is a stateflow? Why is it used?
Stateflow is a graphical programming language tool used for modeling and simulating complex systems with finite state machines.
Stateflow is part of MATLAB/Simulink and allows for visual representation of logic and control flow.
It is commonly used in industries such as automotive, aerospace, and robotics for modeling complex systems.
Stateflow enables engineers to design and simulate state machines, flow charts, and truth tables.
It helps in analyzing and debugging complex contr...read more
Q20. Do dot product using C language
Calculate dot product using C language
Use two arrays of numbers to calculate the dot product
Iterate through the arrays and multiply corresponding elements, then sum the results
Ensure both arrays are of the same length
Q21. Reverse a linked list
Reverse a linked list by changing the next pointers of each node to point to the previous node.
Start with three pointers: current, previous, and next.
Iterate through the list, updating the next pointer of each node to point to the previous node.
Update the previous, current, and next pointers for each iteration.
Q22. Explain memory management
Memory management is the process of controlling and coordinating computer memory, assigning portions called blocks to various programs.
Memory management involves allocation, deallocation, and organization of memory blocks.
It ensures that each process gets the memory it needs and that memory is used efficiently.
Examples include dynamic memory allocation in C/C++, garbage collection in Java, and virtual memory management in operating systems.
Q23. Define sampling theorem
Sampling theorem states that a continuous signal can be accurately represented by discrete samples if the sampling rate is at least twice the highest frequency component of the signal.
The sampling theorem, also known as Nyquist-Shannon sampling theorem, is essential in digital signal processing.
It states that in order to accurately reconstruct a continuous signal from its samples, the sampling rate must be at least twice the highest frequency component of the signal.
If the sa...read more
Q24. Explain polymorphism
Polymorphism is the ability of a single function or method to operate on different types of data.
Polymorphism allows objects of different classes to be treated as objects of a common superclass.
There are two types of polymorphism: compile-time (method overloading) and runtime (method overriding).
Example: Inheritance in object-oriented programming languages like Java allows for polymorphism.
Q25. Interest in Matlab
I have a strong interest in Matlab due to its powerful data analysis and visualization capabilities.
I have experience using Matlab for data analysis and visualization in my academic projects.
I find Matlab's syntax to be intuitive and easy to learn.
I appreciate Matlab's extensive library of functions for various mathematical and engineering tasks.
Top HR Questions asked in MathWorks
Interview Process at MathWorks

Top Interview Questions from Similar Companies








Reviews
Interviews
Salaries
Users/Month

