Tech Mahindra interview experience Real time questions & tips from candidates to crack your interview

SDE - 2

Tech Mahindra
upvote
share-icon
2 rounds | 5 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 2 months
Topics: Data Structures, Pointers, OOPS, System Design, Algorithms, Dynamic Programming
Tip
Tip

Tip 1 : Solve RS Aggarwal Aptitude and Problem Solving Books.
Tip 2 : Practice Coding questions from prepInsta.
Tip 3 : Worked on communication skills

Application process
Where: Referral
Eligibility: 7 CGPA
Resume Tip
Resume tip

Tip 1 : Mark skills with Bold letters.
Tip 2 : Mention projects on resume

Interview rounds

01
Round
Easy
Online Coding Test
Duration30 minutes
Interview date9 Aug 2022
Coding problem4

1. Minimum Operations

Easy
20m average time
82% success
0/40
Asked in companies
FlipkartMicrosoftShareChat

You are given an array 'ARR' of 'N' positive integers. You need to find the minimum number of operations needed to make all elements of the array equal. You can perform addition, multiplication, subtraction or division with any element on an array element.

Addition, Subtraction, Multiplication or Division on any element of the array will be considered as a single operation.

Example:

If the given array is [1,2,3] then the answer would be 2. One of the ways to make all the elements of the given array equal is by adding 1 to the array element with value 1 and subtracting 1 from the array element with value 3. So that final array would become [2,2,2]. 
Problem approach

s1 - Test case 1: Choose i = 2 and split A[2] = 4 into X = 2, Y = 2 making A = [2, ,2, 2]. Now all elements of the array are equal. 

s2 - Test case 2: 

s3 - Choose i = 2 and split A[2] = 2 into X = 1, Y = 1 making A = [1, 3, 1, 1]. 
s4 - Choose i = 2 and split A[2] = 3 into X = 2, Y = 1 making A = [1, 1, 1, 2, 1]. 
Choose i = 4 and split A[4] = 2 into X = 1, Y = 1 making A = [1, 1, 1, 1, 1, 1]. Now all elements of the array are equal.

Try solving now

2. Magic Grid

Moderate
0/80
Asked in companies
Tech MahindraDunzoHCL Technologies

You are given a magic grid A with R rows and C columns. In the cells of the grid, you will either get magic juice, which increases your strength by |A[i][j]| points, or poison, which takes away |A[i][j]| strength points. If at any point of the journey, the strength points become less than or equal to zero, then you will die.

You have to start from the top-left corner cell (1,1) and reach at the bottom-right corner cell (R,C). From a cell (i,j), you can only move either one cell down or right i.e., to cell (i+1,j) or cell (i,j+1) and you can not move outside the magic grid. You have to find the minimum number of strength points with which you will be able to reach the destination cell.

Try solving now

3. Minimum and Maximum Cost to buy N Candies

Hard
10m average time
90% success
0/120
Asked in companies
Paytm (One97 Communications Limited)Tech MahindraGroww

Ram went to a specialty candy store in Ninjaland which has 'N' candies with different costs.

The Candy shop gives a special offer to its customers. A customer can buy a single candy from the store and get at most 'K' different candies for free. Now, Ram is interested in knowing the maximum and the minimum amount he needs to spend for buying all the candies available in the store.

Note: In both cases, Ram must utilize the offer i.e. if 'K' or more candies are available, he must take 'K' candies for every candy purchase. If less than K candies are available, he must take all candies for a candy purchase.

For Example :

For 'N' =  5 and 'K' = 2

Let the cost of different candies in the store be: [9 8 2 6 4]

For the minimum amount: 
Ram can buy a candy with cost 2 and take candies with costs 9 and 8 for free. 
Then, he can buy a candy with cost 4 and take candy with cost 7 for free. 
Thus, the minimum cost will be 6 i.e. 2 + 4. 

For the maximum amount: 
Ram can buy a candy with cost 9 and take candies with costs 2 and 6 for free. 
Then, he can buy candy at cost 8 and take candy at cost 4 for free. 
Thus, the minimum cost will be 17 i.e. 9 + 8.

Thus, Minimum = 6 and Maximum = 17.
Problem approach

s1 - sequence of N candies in the store
s2 - the i-th candy is denoted by Ai.
s3 - value of subarray AL, AL+1, ..., AR is defined as AL+AR
s4 - As the answer can be pretty large output it modulo 1000000007 (109+7)

Try solving now

4. Minimum Number Of Vertices To Reach All Nodes

Moderate
25m average time
75% success
0/80
Asked in companies
FacebookTech MahindraMorgan Stanley

Given a directed acyclic graph having ‘N’ nodes. A matrix ‘edges’ of size M x 2 is given which represents the ‘M’ edges such that there is an edge directed from node edges[i][0] to node edges[i][1].

Find the smallest set of vertices from which all the nodes in the graph are reachable.

Note :

Nodes are numbered from 0 to N - 1.

The graph given is connected.

Print the vertices in sorted order.
For Example :
The following is an example of DAG i.e a directed graph with no cycles in it. 

alt
text

In the above graph, we can reach all the vertices from node a.

Problem approach

s1 : Add an edge between nodes 1 and 2 and another edge between nodes 1 and 3. Now the nodes 1, 2 and 3 form the largest component.

s2 : Nodes 2 and 3 are connected with an edge.

s3 : Add an edge between nodes 2 and 4. Now the nodes 2, 3 and 4 form the largest component.

s4 : Nodes 1 and 5 are connected with an edge.

s5 : Nodes 1 and 2 are connected with an edge.

s6 : Add an edge between nodes 4 and 5. Now the nodes 1, 2, 3, 4 and 5 form the largest component.

Try solving now
02
Round
Easy
HR Round
Duration20 minutes
Interview date16 Aug 2022
Coding problem1

- Morning time
- Environment was good.
- No
- Interviewer was good

1. Basic HR Questions

How would your current manager describe you? 

What would you change about your current job description? 

How do you stay organized in your current position? 

Tell about a time when you made a mistake. 

What did you do to fix it?

Problem approach

Tip 1 : Communication is must
Tip 2 : Practice more by Interview sites

Here's your problem of the day

Solving this problem will increase your chance to get selected in this company

Skill covered: Programming

Which array operation has O(n) worst-case time complexity?

Choose another skill to practice
Similar interview experiences
company logo
SDE - 2
3 rounds | 5 problems
Interviewed by Tech Mahindra
1275 views
0 comments
0 upvotes
company logo
SDE - 1
2 rounds | 6 problems
Interviewed by Tech Mahindra
0 views
0 comments
0 upvotes
company logo
Software Engineer
2 rounds | 2 problems
Interviewed by Tech Mahindra
1997 views
1 comments
0 upvotes
company logo
SDE - 2
3 rounds | 3 problems
Interviewed by Tech Mahindra
899 views
0 comments
0 upvotes
Companies with similar interview experiences
company logo
SDE - 2
3 rounds | 4 problems
Interviewed by HashedIn
8522 views
0 comments
0 upvotes
company logo
SDE - 2
3 rounds | 4 problems
Interviewed by Arcesium
1410 views
0 comments
0 upvotes
company logo
SDE - 2
3 rounds | 3 problems
Interviewed by Tata Consultancy Services (TCS)
1481 views
0 comments
0 upvotes