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

Graduate Engineer Trainee

Tech Mahindra
upvote
share-icon
4 rounds | 22 Coding problems

Interview preparation journey

expand-icon
Journey
I started my preparation when I was in my third year. Then, I took a course in competitive programming from Coding Ninja. It helped me a lot in my DSA concepts and especially in my logical thinking as well. After the completion of my course, I started practicing coding on different platforms.
Application story
I applied through on campus. it has 5 rounds ROUND 1 APTITUDE TEST, ENGLISH ESSAY/STORY ROUND 2: TECHNICAL & PSYCHOMETRIC TEST[ ROUND 3: CONVERSATIONAL TEST ROUND 4: TECHNICAL INTERVIEW ROUND 5: HR INTERVIEW
Why selected/rejected for the role?
I got rejected mail after a technical round because I was not able to answer some questions properly. I got stuck on some questions.
Preparation
Duration: 2 months
Topics: array, string, linked list, oops concept, stack
Tip
Tip

Tip 1: Do practice coding questions regularly on coding platforms. 
Tip 2: Before going interview. Check the interview experience. You will get some ideas.
Tip 3: Maintain your consistency.

Application process
Where: Campus
Eligibility: B-tech CSE IT ECE EEE 2023 (60%)
Resume Tip
Resume tip

Tip 1: Don't write false information in your resume.
Tip 2: Be prepared with your resume.

Interview rounds

01
Round
Medium
Online Coding Interview
Duration90 mins
Interview date13 Oct 2022
Coding problem8

In this round, questions are based on numerical ability, verbal ability, logical ability, and computer fundamentals. The duration of the test is around 90 minutes, scheduled for 13 December. Mainly, they are focusing on the aptitude part, which I was able to clear this round. The questions were quite easy, although some were tricky. I can say the level of this round is easy to moderate. Additionally, 1-2 coding questions were also included.

1. Missing and repeating numbers

Moderate
25m average time
75% success
0/80
Asked in companies
FlipkartGrowwAmazon

You are given an array of size ‘N’. The elements of the array are in the range from 1 to ‘N’.

Ideally, the array should contain elements from 1 to ‘N’. But due to some miscalculations, there is a number R in the range [1, N] which appears in the array twice and another number M in the range [1, N] which is missing from the array.

Your task is to find the missing number (M) and the repeating number (R).

For example:
Consider an array of size six. The elements of the array are { 6, 4, 3, 5, 5, 1 }. 
The array should contain elements from one to six. Here, 2 is not present and 5 is occurring twice. Thus, 2 is the missing number (M) and 5 is the repeating number (R). 
Follow Up
Can you do this in linear time and constant additional space? 
Problem approach

Traverse all elements and put them in a hash table. Element is used as the key and the count of occurrences is used as the value in the hash table. 
Traverse the array again and print the element with count 1 in the hash table.

Try solving now

2. Guess the output question

nteger value, n
Set value = 1, n = 45
while(value less than equal to n)
 value = value << 1
end loop
Print value

A 16
B 32
C 64
D 36

Problem approach

Ans:- C) 64 

Firstly variables n and value are initialized, then n and value are assigned values 45 and 1 respectively.
Now run a while loop will until the value becomes greater than 45, in each iteration of the loop perform a left shift by 1(multiply by 2) operation on the value variable.

Thus the value changes in order 1, 2, 4, 8, 16, and 32 till here the value is less than 45 then again perform the operation value << 1, value = 64 and the while loop terminates.

3. Guess the output question

Integer a, b, c 
Set b = 4, c = 5 
for(each a from 2 to 4) 
 print c 
 b = b - 1 
 c = c + b 
end for
A
5 8 10
B
1 3 6
C
8 9 10
D
3 6 9

Problem approach

Firstly variables a, b, and c are initialized, then b and c are assigned values 4 and 5 respectively. 
Now run a loop from 2 to 4, in each iteration b is decremented by 1, and c is incremented by b. 
In the first iteration print c = 5 value of b is decremented by 1 i.e. b = 3, c is incremented by b i.e. c = 5 
In the second iteration print c = 8 value of b is decremented by 1 i.e. b = 2, c is incremented by b i.e. c = 8 
In the third iteration print c = 10 value of b is decremented by 1 i.e. b = 1, c is incremented by b i.e. c = 10 

Thus the final series is A) 5, 8, 10

4. Guess the Output

#include 
int main()
{
if (remove("myfile.txt") != 0)
 perror("Error");
else
 puts("Success");
return 0;
}

Options:
a) Error
b) Success
c) Runtime Error
d) Can’t say

Problem approach

Ans:- D) 
If myfile.txt exists, then it will delete the file. Else it will print an error message.

5. DBMS MCQ

Which type of data can be stored in the database?
a) Image-oriented data
b) Text, files containing data
c) Data in the form of audio or video
d) All of the above

6. OS MCQ

CPU scheduling is the basis of 
a) multiprogramming operating systems
b) larger memory sized systems
c) multiprocessor systems
d) none of the mentioned

Problem approach

Tip 1: you can do numeric ability questions the logical ability and verbal ability
Tip 2: practice ques from the interview bit
 

7. Puzzle

A boat can travel at a speed of 13 km/hr in still water. If the speed of the stream is 4 km/hr, find the time taken by the boat to go 68 km downstream.

A. 2 hours
B. 3 hours
C. 4 hours
D. 5 hours

Problem approach

Tip 1: you can do numeric ability questions the logical ability and verbal ability
Tip 2: practice ques from the interview bit
 

8. Armstrong Number

Easy
15m average time
85% success
0/40
Asked in companies
OracleIBMOptum

You are given an integer ‘NUM’ . Your task is to find out whether this number is an Armstrong number or not.

A k-digit number ‘NUM’ is an Armstrong number if and only if the k-th power of each digit sums to ‘NUM’.

Example
153 = 1^3 + 5^3 + 3^3.

Therefore 153 is an Armstrong number.
Problem approach

The idea is to first count the number of digits (or find the order). Let the number of digits be n. For every digit r in input number x, compute rn. If sum of all such values is equal to n, then return true, else false.

Try solving now
02
Round
Medium
Online Coding Test
Duration60 mins
Interview date27 Oct 2022
Coding problem2

Here are two coding questions some pseudocode and also the dsa concept. this level is not hard to moderate. Lastly, there is a psychometric test which is very simple and easy. the platform is SHL.

1. Reverse Words In A String

Easy
10m average time
90% success
0/40
Asked in companies
Thought WorksFacebookApple

You are given a string 'str' of length 'N'.


Your task is to reverse the original string word by word.


There can be multiple spaces between two words and there can be leading or trailing spaces but in the output reversed string you need to put a single space between two words, and your reversed string should not contain leading or trailing spaces.


Example :
If the given input string is "Welcome to Coding Ninjas", then you should return "Ninjas Coding to Welcome" as the reversed string has only a single space between two words and there is no leading or trailing space.
Problem approach

i used stack in this question

Try solving now

2. Cycle Detection in a Singly Linked List

Moderate
15m average time
80% success
0/80
Asked in companies
ThalesCIS - Cyber InfrastructureUrban Company (UrbanClap)

You are given a Singly Linked List of integers. Return true if it has a cycle, else return false.


A cycle occurs when a node's next points back to a previous node in the list.


Example:
In the given linked list, there is a cycle, hence we return true.

Sample Example 1

Problem approach

Traverse the list individually and keep putting the node addresses in a Hash Table. 
At any point, if NULL is reached then return false 
If the next of the current nodes points to any of the previously stored nodes in Hash then return true.

Try solving now
03
Round
Medium
Video Call
Duration30 mins
Interview date3 Nov 2022
Coding problem6

CONVERSATIONAL TEST

1. Count Ways To Reach The N-th Stairs

Moderate
30m average time
80% success
0/80
Asked in companies
Expedia GroupFreshworksInfosys

You have been given a number of stairs. Initially, you are at the 0th stair, and you need to reach the Nth stair.


Each time, you can climb either one step or two steps.


You are supposed to return the number of distinct ways you can climb from the 0th step to the Nth step.

Example :
N=3

Example

We can climb one step at a time i.e. {(0, 1) ,(1, 2),(2,3)} or we can climb the first two-step and then one step i.e. {(0,2),(1, 3)} or we can climb first one step and then two step i.e. {(0,1), (1,3)}.
Try solving now

2. All Prime Numbers less than or equal to N

Moderate
10m average time
90% success
0/80
Asked in companies
Tech MahindraOptumIBM

You are given a positive integer 'N'. Your task is to return all the prime numbers less than or equal to the 'N'.

Note:

1) A prime number is a number that has only two factors: 1 and the number itself.

2) 1 is not a prime number.
Problem approach

First, take the number N as input.
Then use a for loop to iterate the numbers from 1 to N
Then check for each number to be a prime number. If it is a prime number, print it.

Try solving now

3. Technical MCQ

Which will be used with physical devices to interact with C++ programs?
a) Programs
b) Library
c) Streams
d) Iterators

4. Puzzle

There are 3 women and 3 men They all have to cross a river in a boat. The boat can only carry two people at a time. As long as there are an equal number of devils and priests, then devils will not eat Priest. If the number of devils is greater than the number of priests on the same side of the river then devils will eat the priests. So how can we make all the 8 people arrive on the other side safely?

5. Technical Question

What is the time complexity used for inserting a node in a priority queue based on key is:

Problem approach

O(log N) time

6. Technical MCQ

Which of the following is a linear data structure?
a> array
b> AVL tree
c> binary search
d> graph

04
Round
Medium
Video Call
Duration20 min
Interview date9 Nov 2022
Coding problem6

1. N-th Fibonacci Number

Moderate
40m average time
70% success
0/80
Asked in companies
AmazonWalmartTata Consultancy Services (TCS)

You are given an integer ‘N’, your task is to find and return the N’th Fibonacci number using matrix exponentiation.

Since the answer can be very large, return the answer modulo 10^9 +7.

Fibonacci number is calculated using the following formula:
F(n) = F(n-1) + F(n-2), 
Where, F(1) = F(2) = 1.
For Example:
For ‘N’ = 5, the output will be 5.
Problem approach

i used recursion

Try solving now

2. OOPs Questions

Difference between overriding and overloading
What is polymorphism?

3. OOPs Questions

what is the static class?

what is a constructor?

Types of constructors?

4. C++ Questions

In C++ he asked to share screen and write syntaxes of string compare and syntaxes of polymorphism types.

5. DBMS questions

Q1> What is super key?
Q2> What is primary key?
Q3> What is normalisation?

6. Power Of 2

Moderate
20m average time
70% success
0/80
Asked in companies
GoogleCIS - Cyber InfrastructureInfosys

You are given an integer ‘N’. We can reorder the digits in any order (including the original order) such that the leading digit is not zero.

Return true if and only if we can do this so that the resulting number is a power of two. Else, return false.

For Example :

Given :-
‘N’ = 218
Then the answer will be true because it can be rearranged to 128, which is 2 raised to the power of 7.
Problem approach

A simple method for this is to simply take the log of the number on base 2 and if you get an integer then the number is the power of 2

Try solving now

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
Graduate Engineer Trainee
2 rounds | 3 problems
Interviewed by Tech Mahindra
849 views
0 comments
0 upvotes
company logo
Graduate Engineer Trainee
5 rounds | 11 problems
Interviewed by Tech Mahindra
1707 views
1 comments
0 upvotes
company logo
Software Developer
3 rounds | 18 problems
Interviewed by Tech Mahindra
824 views
0 comments
0 upvotes
company logo
Associate Software Engineer
5 rounds | 2 problems
Interviewed by Tech Mahindra
683 views
0 comments
0 upvotes
Companies with similar interview experiences
company logo
Graduate Engineer Trainee
2 rounds | 5 problems
Interviewed by HCL Technologies
12625 views
3 comments
0 upvotes
company logo
Graduate Engineer Trainee
3 rounds | 4 problems
Interviewed by HCL Technologies
2300 views
0 comments
0 upvotes
company logo
Graduate Engineer Trainee
2 rounds | 2 problems
Interviewed by HCL Technologies
2350 views
0 comments
0 upvotes