Josh Technology Group
Mahindra Automotives Interview Questions and Answers
Q1. Non-Decreasing Array Problem Statement
Given an integer array ARR
of size N
, determine if it can be transformed into a non-decreasing array by modifying at most one element.
An array is defined as non-decreasin...read more
The solution checks if an integer array can become non-decreasing by modifying at most one element.
Iterate through the array and check if there are more than one decreasing pairs of elements.
If there are more than one decreasing pairs, return false.
If there is only one decreasing pair, check if modifying one of the elements can make the array non-decreasing.
If modifying the element at index i-1 or i can make the array non-decreasing, return true.
Otherwise, return false.
Q2. Find Unique Element in Array
You have been provided an integer array/list ARR
of size N
. Here, N
is equivalent to 2M + 1
where each test case has M
numbers appearing twice and one number appearing exactly once....read more
The task is to find the unique number in an array where all other numbers occur twice.
The array size is given by N = 2M + 1, where M is the number of elements occurring twice.
Loop through the array and use a hashmap to count the occurrences of each number.
Return the number with a count of 1, as it is the unique number.
Q3. Sort Linked List Based on Actual Values
You are given a Singly Linked List of integers that is initially sorted according to the absolute values of its elements. Your task is to sort this Linked List based on t...read more
The task is to sort a singly linked list based on actual values instead of absolute values.
Traverse the linked list and store the values in an array
Sort the array using any sorting algorithm
Create a new linked list using the sorted array
Return the new linked list
Q4. Check If Linked List Is Palindrome
Given a singly linked list of integers, determine if the linked list is a palindrome.
Explanation:
A linked list is considered a palindrome if it reads the same forwards and b...read more
Diameter of a Binary Tree Problem Statement
Given a binary tree, return the length of its diameter. The diameter of a binary tree is defined as the length of the longest path between any two nodes in the tree.
The diameter of a binary tree is the length of the longest path between any two end nodes in the tree.
The diameter of a binary tree can be calculated by finding the maximum of the following three values: 1) the diameter of the left subtree, 2) the diameter of the right subtree, and 3) the longest path that passes through the root node.
To find the diameter of a binary tree, we can use a recursive approach. We calculate the height of the left and right subtrees, and then calcul...read more
Q6. Merge K Sorted Arrays Problem Statement
Given 'K' different arrays that are individually sorted in ascending order, merge all these arrays into a single array that is also sorted in ascending order.
Input
The f...read more
Q7. Remove Duplicates Problem Statement
You are given an array of integers. The task is to remove all duplicate elements and return the array while maintaining the order in which the elements were provided.
Example...read more
Q8. Segregate Odd-Even Problem Statement
In a wedding ceremony at NinjaLand, attendees are blindfolded. People from the bride’s side hold odd numbers, while people from the groom’s side hold even numbers. For the g...read more
Top HR Questions asked in Mahindra Automotives
Interview Process at Mahindra Automotives
Top Front end Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month