 Prepare
 All Platforms
 Programming
 Aptitude
 Syllabus
 Interview Preparation
 Interview Exp.
 Off Campus
 Prime Video
 Prime Mock
 PrepInsta Prime
 OffCampus
 The Job Company
 Placement Stats
 Prime Video
 Prime Mock
 ^{0}
Notifications Mark All Read
 Login
 Get Prime
Tech Mahindra Menu
 Previous Papers
 Tech Mahindra Syllabus
 Quantitative Aptitude
 Verbal English
 Logical Ability
 English Essay
 Conversational Assessment
 Computer Science
 Computer Programming
 Super Coder
 Coding
 Tech Test
 Personality Test
 Tech Mahindra Eligibility Criteria
 Tech Mahindra Recruitment Process
 Interview Questions
Tech Mahindra Super Coder Questions and Answers
Tech Mahindra Super Coder Questions with Solutions
Tech Mahindra Coding Questions and Answers are discussed on this page, which were asked in the Coding Assessment and Technical Interviews of the company for hiring the Tech Mahindra Super Coder.
Here we have mentioned other details related to Tech Mahindra recruitment processes like Job profiles, CTC offered, and Steps involved in Recruitment Process to hire Tech Mahindra Super Coder.
About Tech Mahindra
Tech Mahindra is a multinational information technology (IT) company based in India. It was founded in 1986 and is part of the Mahindra Group.
Tech Mahindra offers a range of IT services, including software development, system integration, network management, data analytics, and digital transformation solutions. It serves clients in various sectors such as banking and financial services, telecommunications, healthcare, manufacturing, retail, and transportation.
About Tech Mahindra Recruitment Process 2024
Tech Mahindra announced the hiring of freshers for 2 Job Profiles – Assistant Engineer and Super Coder. For the Assistant Engineer post we have mentioned the following steps:
 Online Aptitude Test
 Psychometric Test
 Technical Test
 HR Interview
After clearing these rounds Tech Mahindra is inviting the candidates to participate in Super Coder Contest.
We have mentioned further details of the Tech Mahindra Super Coder Recruitment Process in the following Tabular Form
Tech Mahindra  Related Information 

Position:  Super Coder 
Course: 

Eligibility Criteria / Academic Qualification Required: 

CTC Offered: 

Selection Process: 

Test Duration: 
1 Hour 30 Minutes 
Use Coupon Code “CT10” and get flat 10% OFF on your Prime Subscription :
 1 month extra subscription on 3 & 6 months plans
 2 months extra subscription on 12 & 24 months plans
 3 months extra subscription on 36 & 48 months plan
(Use Coupon Code “CT10″ and get 10% off and additional months)
Prime Course Trailer
Related Banners
Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription
Tech Mahindra Super Coder Questions with Solutions
Question 1 : Buying Stocks
Example
Prices=[10,4,2,9]
The greatest loss is incurred when you buy at a price of 10 and sell at a price of 2. Return the difference:9.
Example
Price=[1,2,3,4]
The Price went up every day. Return 0.
Sample Input for Custom Testing
STDIN Function
———– ————–
 7 → Prices [] size n=7
 1 → prices =[1,8,4,2,10,3,2]
 8
 4
 2
 10
 3
 2
Sample Output
 8
Explanation
Using zerobased index notation, the correct answer is a[4]a[6]=102=8. There is a greater difference between 10 and 1 but that would imply selling before buying, and short selling is not allowed in this problem.
#include<bits/stdc++.h> #define ll long long using namespace std; int solve(vector v) { int n = v.size(); if (n == 0) return 0; int mx = v[0]; for (int i = 1; i < n; i++) mx = max(mx, v[i]); if (mx <= 0) return 0; int mxSum = 0; int cSum = 0; for (int i = 0; i < n; i++) { cSum += v[i]; if (cSum < 0) cSum = 0; mxSum = max(mxSum, cSum); } return mxSum; } int main() { int n; cin >> n; int price[n]; for (int i = 0; i < n; i++) { cin >> price[i]; } vector diff; for (int i = n2; i >=0 ; i) diff.push_back(price[i]  price[i+1]); int ans = solve(diff); if(ans<0) { cout<<0<< endl; } else { cout<< ans<< endl; } return 0; }
n=int(input()) arr=[] ans=[0] for i in range(n): arr.append(int(input())) for i in range(n1): x=min(arr[i+1:])arr[i] if x<0: ans.append(x) print(1*min(ans))
import java.util.*; class Solution { public static int solve(ArrayList < Integer > list) { int n = list.size(); if (n == 0) return 0; int max = list.get(0); for (int i = 1; i < n; i++) max = Math.max(max, list.get(i)); if (max <= 0) return 0; int maxSum = 0; int sum = 0; for (int i = 0; i < n; i++) { sum = sum + list.get(i); if (sum < 0) sum = 0; maxSum = Math.max(maxSum, sum); } return maxSum; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int arr[] = new int[n]; for (int i = 0; i < n; i++) arr[i] = sc.nextInt(); ArrayList < Integer > list = new ArrayList(); for (int i = n  2; i >= 0; i) list.add(arr[i]  arr[i + 1]); int res = solve(list); if (res < 0) System.out.println(0); else System.out.println(res); } }
Question 2: k th largest factor of N
Problem Description:
A positive integer d is said to be a factor of another positive integer N if when N is divided by d, the remainder obtained is zero. For example, for number 12, there are 6 factors 1, 2, 3, 4, 6, 12. Every positive integer k has at least two factors, 1 and the number k itself. Given two positive integers N and k, write a program to print the kth largest factor of N.
Input Format: The input is a commaseparated list of positive integer pairs (N, k).
Output Format: The k^{th} highest factor of N. If N does not have k factors, the output should be 1.
Constraints:
 1<N<10000000000
 1<k<600.
You can assume that N will have no prime factors which are larger than 13.
Example 1
 Input: 12,3
 Output: 4
Explanation: N is 12, k is 3. The factors of 12 are (1,2,3,4,6,12). The highest factor is 12 and the third largest factor is 4. The output must be 4.
Example 2
 Input: 30,9
 Output: 1
Explanation: N is 30, k is 9. The factors of 30 are (1,2,3,5,6,10,15,30). There are only 8 factors. As k is more than the number of factors, the output is 1.
#include void main() { int number,pos_of_factor,i,c=0; scanf("%d",&number); scanf("%d",&pos_of_factor); for(i=number;i>=1;i) { if((number%i)==0) c++; if(c==pos_of_factor) { printf("%d",i); break; } } if(c<pos_of_factor) printf("1"); }
Output 12,3 4
#include using namespace std; int main() { int number,pos_of_factor,i,c=0; cin>>number; cin>>pos_of_factor; for(i=number;i>=1;i) { if((number%i)==0) c++; if(c==pos_of_factor) { cout<<i; break; } } if(c<pos_of_factor) cout<<1; return 0; }
Output 12,3 4
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int number,r,i,count=0; number = sc.nextInt(); r = sc.nextInt(); for (i = number; i >= 1; i) { if((number%i)==0) count++; if(count==r) { System.out.println(i); break; } } if(count!=r) System.out.println(1); } }
Output 12,3 4
number, k = [int(i) for i in input().split(",")] factor = [] count = 0 for i in range(1, number+1): if number % i == 0: count = count + 1 factor.append(i) if count < k: print("1") else: print(factor[k])
Output 12,3 4
Question 3: Street Light Installation
Street Lights are installed at every position along a 1D road of length n.
Locations[] (an array) represent the coverage limit of these lights. The ith light has a coverage limit of locations[i] that can range from the position max((i – locations[i]), 1) to min((i + locations[i]), n ) (Closed intervals). Initially all the lights are switched off. Find the minimum number of fountains that must be switched on to cover the road.
Example
n = 3
locations[] = {0, 2, 13}then
For position 1: locations[1] = 0, max((1 – 0),
1) to mini (1+0), 3) gives range = 1 to 1
For position 2: locations[2] = 2, max((22),
1) to min( (2+2), 3) gives range = 1 to 3
For position 3: locations[3] = 1, max( (31),
1) to min( (3+1), 3) gives range = 2 to 3
For the entire length of this road to be covered, only the light at position 2 needs to be activated.
Function Description
Returns
int: the minimum number of street lights that must be activated
Constraints
 1<_n<_ 10^5
 O<_locations[i] <_ mini (n,100) (where 1 <_1<_
10^5)
► Input Format For Custom Testing
Sample Case 0
Sample Input For Custom Testing
3 >locations[] size n = 3
1 >locations[] [1, 1, 1]
1 >Sample Output
Sample Output
1
#include <bits/stdc++.h> #define ll long long using namespace std; bool compare(pair<int, int> A, pair<int, int> B) { if (A.first = B.first) return A.second < B.second; return A.first < B.first; } int solve(int location[], int n) { pair<int, int> range[n]; for (int i = 0; i < n; i++) { int id = i + 1; range[i].first = max(1, id  location[i]); range[i].second = min(n, id + location[i]); } sort(range, range + n, compare); int i = 0; int ans = 0; while (i < n) { pair<int, int> p = range[i]; ans++; while (i + 1 < n && range[i].first == range[i + 1].first) { p.second = max(p.second, range[i + 1].second); i++; } //cout<<p.second<<" "<<i<<endl; while (i < n && range[i].second <= p.second) i++; //cout<<p.second<<" "<<i<<endl; } return ans; } int main() { int n; cin >> n; int location[n]; for (int i = 0; i < n; i++) cin >> location[i]; cout << solve(location, n) << endl; return 0; }
Question 4: Parallel Columbus
Problem Statement – Nobel Prizewinning AustrianIrish physicist Erwin Schrödinger developed a machine and brought as many Christopher Columbus from as many parallel universes as he could. Actually, he was quite amused by the fact that Columbus tried to find India and got America. He planned to dig it further.
Though totally for research purposes, he made a grid of size n X m, and planted some people of America in a position (x,y) [in 1 based indexing of the grid], and then planted you with some of your friends in the (n,m) position of the grid. Now he gathered all the Columbus in 1,1 positions and started a race.
Given the values for n, m, x, y, you have to tell how many different Columbus(s) together will explore you as India for the first time.
Remember, the Columbus who will reach to the people of America, will be thinking that as India and hence wont come further.
Function Description:
Complete the markgame function in the editor below. It has the following parameter(s):
Parameters:
Name  Type  Description 
n  Integer  The number of rows in the grid. 
m  Integer  The number of columns in the grid. 
x  Integer  The American cell’s Row. 
y  Integer  The American cell’s Column. 
Constraints:
 1 <= n <= 10^2
 1 <= m <= 10^2
 1 <= x <= n
 1 <= y <= m
Input Format:
 The first line contains an integer, n, denoting the number of rows in the grid.
 The next line contains an integer m, denoting the number of columns in the grid.
 The next line contains an integer, x, denoting the American cell’s row.
 The next line contains an integer, y, denoting the American cell’s column.
Sample Cases
Sample Input 1
2
2
2
1
Sample Output 1
1
Explanation
The only way possible is (1,1) >(2,1) > (2,2), so the answer is 1.
#include<bits/stdc++.h> using namespace std; unordered_map<int,long long int> f; long long int Fact(int n) { if(f[n]) return f[n]; return f[n]=n*Fact(n1); } int main() { int n,m,x,y; cin>>n>>m>>x>>y; n=1;m=1;x=1;y=1; f[0]=f[1]=1; int p=(Fact(m+n)/(Fact(m)*Fact(n))); int imp=((Fact(x+y)/(Fact(x)*Fact(y)))*(Fact(mx+ny)/(Fact(mx)*Fact(ny)))); cout<<pimp; }
import math n=int(input())1 m=int(input())1 x=int(input())1 y=int(input())1 ans=math.factorial(n+m) ans=ans//(math.factorial(n)) ans=ans//(math.factorial(m)) ans1=math.factorial(x+y) ans1=ans1//(math.factorial(x)) ans1=ans1//(math.factorial(y)) x1=nx y1=my ans2=math.factorial(x1+y1) ans2=ans2//(math.factorial(x1)) ans2=ans2//(math.factorial(y1)) print(ans(ans1*ans2))
import java.util.*; class Main { static int f[] = new int[1000]; static int Fact(int n) { if(f[n]==1) return f[n]; return f[n]=n*Fact(n1); } public static void main (String[]args) { Scanner sc = new Scanner (System.in); int n = sc.nextInt (); int m = sc.nextInt (); int x = sc.nextInt (); int y = sc.nextInt (); n=1;m=1;x=1;y=1; f[0]=f[1]=1; int p=(Fact(m+n)/(Fact(m)*Fact(n))); int imp=((Fact(x+y)/(Fact(x)*Fact(y)))*(Fact(mx+ny)/(Fact(mx)*Fact(ny)))); System.out.println(pimp); } }
Question 5: Find the homeless
Problem Statement : There are N Homeless people in the community and N houses in the community. It will be given in the array (people), the height of the person, and in the array house capacity of the house is given.
The government decided to give homes to people on the basis of the following conditions:
 Priority is given to the people from left to right of the array
 Each person is allotted to a house if and only if the capacity of the house is greater than or equal to the person’s height
 Nearby empty Houses are allotted to the person( starting from the extreme left)
You need to find the number of homeless people who have not been allotted any home if the government follows the above conditions. So that government will have an idea of how many people they need to allot homes for next time.
Constraints:
 1 <= N <= 10^3
 1 <= people[i] <= 10^5
 1 <= house[i] <= 10^5
Input Format for Custom Testing:
 The first line contains an integer, N, denoting the number of people and number of houses.
 Each line i of the N subsequent lines (where 0 <= i <= N) contains an integer describing peoplei.
 Each line i of the N subsequent lines (where 0 <= i <= N) contains an integer describing housei.
Sample Test Cases
 Sample Input 1
3
4
2
7
3
5
10  Sample Output 1
0  Explanation
people=[4,2,7]
house=[3,5,10]
People[0] has more priority , from left to right order in houses 5 is the nearest one which fits for people[0]
people[1]=2 will fit in 3 which is nearer from left
people[2]=7 will fit in remaining house of capacity of 10
So no homeless people left so return 0
 Sample Input 2
3
3
8
5
1
9
4  Sample Output 2
2  Explanation
people=[3,8,5]
house=[1,9,4]
people[0]=3 can fit in 9 which is nearest from left in array house
people[1]=8 cannot fit in any home which is left (i.e, 1 and 4)
people[2]=5 cannot fit in any home which is left (i.e, 1 and 4)
So return 2,which is number of homeless people
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; int people[n], house[n]; for(int i=0; i<n; i++) cin>>people[i]; for(int i=0; i<n; i++) cin>>house[i]; int count = 0; for(int i=0; i<n; i++){ for(int j=0; j<n; j++){ if(people[i]<house[j]){ count+=1 ; house[j]=1; break ; } } } cout<<ncount; }
import java.util.*; class Main { public static void main(String args[]) { Scanner sc = new Scanner (System.in); int n=sc.nextInt(); int people[]= new int[n]; int house[]= new int[n]; for(int i=0; i<n; i++) people[i]=sc.nextInt(); for(int i=0; i<n; i++) house[i]=sc.nextInt(); int count = 0; for(int i=0; i<n; i++){ for(int j=0; j<n; j++){ if(people[i]<house[j]){ count+=1 ; house[j]=1; break ; } } } System.out.println(ncount); } }
N=int(input()) people=[] house=[] #to read data of people and house arrays for i in range(N): people.append(int(input())) for i in range(N): house.append(int(input())) count=0 for i in range(N): for j in range(N): if(people[i] < house[j]): count+=1 house[j]=1 break print(Ncount)
FAQs on Tech Mahindra Super Coder
Question 1: Who are eligible for Tech Mahindra Super Coder Contest?
Candidates who have passed all the rounds required for Assistant Engineer Job Profile are eligible for this Super Coder Contest. They will get an Email invitation from HackerEarth to participate in this round.
Question 2: What are some tips for preparing for a Super Coder technical interview?
One should prepare for Advance Level Data Structures & Algorithms in the chosen language. And should have a clear understanding of Core Subjects of Computer Science like Operating Systems, RDBMS / DBMS, etc.
Question 3: What if the applicants didn't clear the Super Coder Contest?
If the applicants didn’t get passed in Super Coder Contest, they will be offered with the Job profile of Assistant Engineer with a package of ₹ 4 L.P.A.
Get over 200+ course One Subscription
Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others
if a candidate doesn’t pass a particular round in tech mahindra would they be still considered for the hiring process
Hey, All the rounds in this hiring are elimination round. You can text us on 8448440710 for more details.