Tech Mahindra Coding Questions 2024

Tech Mahindra Coding Questions 2024​
About Tech Mahindra :

Tech Mahindra is an Indian multinational technology company that provides information technology (IT) services and business process outsourcing (BPO) solutions. Established in 1986, it is a part of the Mahindra Group, a prominent conglomerate in India. Tech Mahindra operates in various industries, including telecommunications, manufacturing, healthcare, finance, and more. The company specializes in offering services such as software development, system integration, network services, cloud computing, and digital transformation. Tech Mahindra has a global presence, with offices and delivery centers in numerous countries, serving clients across the world. It has gained recognition for its focus on innovation, customer-centric approach, and expertise in emerging technologies. [Tech Mahindra Coding Questions 2024]

Tech Mahindra Technical Round
  • There will be 26 Technical Test Question with in the Tech Mahindra exam, two question will be the Coding Question and rest all question will be Technical MCQ along with there will be 72 Personality Test Questions are also present in the Tech Mahindra Technical Test.
  • The difficulty level of question is medium to high where they will judge your knowledge of programming although overall time to solve the whole Tech Test Question is 90 minutes including 72 Personality Test Questions. so, you can give approximately 15-20 minutes to coding question in the exam. [Tech Mahindra Coding Questions 2024]

Also Read About : Tech Mahindra Hiring Process 2024: Eligibility, Test Pattern, Detail Syllabus and More.

Technical Round

Technical Round Total Questions Total Time
Computer Programming 12 15 mins
Computer Science 12 15 mins
Automata Fix [Coding Questions] 2 45 mins
Personality Test 72 15 mins
Total Sections : 4 98 Questions 90 mins

Tech Mahindra Coding Questions 2024​

Question 1 : Count Non-repeated Character in String

A data compression software utilizes various steps to compress a string of data. One of the steps involves finding the count of characters that are not repeated in the string.

Write an algorithm for the software developer to find the count of characters that are not repeated in the string.

Input Format

The input consists of a string.
compString representing the string to be compressed.

Output

Print an integer representing the count of characters that are not repeated in the string. If no such character is found or the input string is empty then print 0.

Note

The input string compString is case sensitive. Uppercase characters and lowercase characters are counted as different. The input string compString consists of alphanumeric and special characters only.

Example

Input:  alphaadida

Output: 4

 
Explanation :  ** Non repeated characters are l, p ,h ,i **

[Tech Mahindra Coding Questions 2024]

Solution :
Question 2 : Difference Between the Count of Odd numbers and Even numbers

Write a program to return the difference between the count of odd numbers and even numbers.

Note : You are expected to write code in the countOddEvenDifference function only which will receive the first parameter as the number of items in the array and second parameter as the array itself. you are not required to take input from the console.

Example

Finding the difference between the count of odd and even numbers from a list of 8  number

Input1 :  8

Input2 :  10 20 30 40 55 66 77 83

Output: -2

 
Explanation :

The first paramter (8) is the szie of the array. Next is an array of integers. The calculation of difference between count sum of odd and even numbers is as follows:

3 (count of odd numbers) – 5 (count of even numbers) = -2    [Tech Mahindra Coding Questions 2024]

Solution :
Question 3 : Write a program to calculate and return the sum of absolute difference between the adjacent number in an array

Write a program to calculate and return the sum of absolute difference between the adjacent number in an array of positive integers from the position entered by the user.

Note : You are expected to write code in the findTotalSum function only which receive three positional arguments:

1st : number of elements in the array
2nd : array
3rd : position from where the sum is to be calculated

Example

Input:  

Input 1 : 7
Input 2 : 11 22 12 24 13 26 14
Input 3 : 5

Output: 25

 
Explanation :

The first parameter 7 is the size of the array. Next is an array of integers and input 5 is the position from where you have to calculate the Total Sum. The output  is 25 as per calculation below. 
| 26-13 | = 13
| 14-26 | =  12
Total Sum = 13 + 12 = 25   [Tech Mahindra Coding Questions 2024]

Solution :
Question 4 : Write a program to find the difference between the elements at odd index and even index.

Write a program to calculate and return the sum of absolute difference between the adjacent number in an array of positive integers from the position entered by the user.

Note : You are expected to write code in the findDifference function only which receive the first parameter as the numbers of items in the array and second parameter as the array itself. You are not required to take the input from the console.

Example

Finding the maximum difference between adjacent items of a list of 5 number

Input:  

Input 1 : 7
Input 2 : 10 20 30 40 50 60 70

Output: 40

 
Explanation :

The first parameter 7 is the size of the array. Sum of element at even index of array is 10 + 30 + 50 + 70 = 160 and sum of elements at odd index of array is 20 + 40 + 60 = 120. The difference between both is 40  [Tech Mahindra Coding Questions 2024]

Solution :
Question 5 : Write a program for Decimal to Binary Conversion

Given a decimal number as input, we need to write a program to convert the given decimal number into an equivalent binary number.

Example

Convert 17 and 33 into it’s respective decimal form

Input:  

Input 1 : 17
Input 2 : 33

Output: 

Ouput1 : 111

Output2 : 100001

[Tech Mahindra Coding Questions 2024]

Solution :
Question 6 : Find a pair with maximum product in array of Integers

Given an array with both +ive and -ive integers, return a pair with the highest product.

Input:  

Input1 : arr[] = {1, 4, 3, 6, 7, 0}  
Input2 : arr[] = {-1, -3, -4, 2, 0, -5} 

Output: 

Output1 : {6,7}

Output2 : {-4,-5}

[Tech Mahindra Coding Questions 2024]

Solution :
Question 7 : Array Sub Array

You are given an array, You have to choose a contiguous subarray of length ‘k’, and find the minimum of that segment, return the maximum of those minimums.

Input:  

1 → Length of segment x =1
5 → size of space n = 5
1 → space = [ 1,2,3,1,2]
2
3
1
2

Output:

3

 
Explanation :

The subarrays of size x = 1 are [1],[2],[3],[1], and [2],Because each subarray only contains 1 element, each value is minimal with respect to the subarray it is in. The maximum of these values is 3. Therefore, the answer is 3.   [Tech Mahindra Coding Questions 2024]

Solution :
Question 8 : Find Total Feet

Given an array of integers representing measurements in inches, write a program to calculate the total of measurements in feet. Ignore the measurements that are less than a foot (eg. 10).

Note: You are expected to write code in the findTotalFeet function only which will receive the first parameter as the number of items in the array and the second parameter as the array itself. You are not required to take input from the console

Example:

Finding the total measurements in feet from a list of 5 numbers

Input:  

5

18 11 27 12 14

Output:

5

 
Explanation :

The first parameter (5) is the size of the array. Next is an array of measurements in inches. The total number of feet is 5 which is calculated as shown below:

18->1

11->0

27->2

12->1

14->1

 [Tech Mahindra Coding Questions 2024]

Solution :
Question 9 : Calculate Total Tax

Write a program to calculate the total bill tax amount for a list of billing amounts passed as an array of long integers.

Up to the amount of 1000, there is no tax applicable, subsequently, a flat tax of 10% is applicable for the remaining amount as per the tax rate.

Note: 

All calculations and results should be integer-based ignoring fractions

You are expected to write code int the calcTotalTax function only which will receive the first parameter as the number of items in the array and the second parameter is the array itself. You are not required to take input from the console.

Example:

Calculating total tax for a list of 5 billing amounts

Input:  

5

1000 2000 3000 4000 5000

Output:

1000

 
Explanation :

The first parameter (5) is the size of the array. Next is an array of billing amounts For the first amount there will be 0 tax and for the next amount, it will be 10% of(2000-1000)=100 and so on.

The sum of all the tax amounts will be (0+100+200+300+400=1000)

[Tech Mahindra Coding Questions 2024]

Solution :
Scroll to Top