Tech Mahindra Placement – Round 2 Coding Questions & Practice Guide
I am an engineering student pursuing a degree in Artificial Intelligence and Data Science at Datta Meghe College of Engineering. I have strong technical skills in Full Stack Web Development, as well as programming in Python and Java. I currently manage Doubtly's blog and am exploring job opportunities as an SDE. I am passionate about learning new technologies and contributing to the tech community.
Hey everyone! 👋
Recently, I appeared for the Tech Mahindra placement process and successfully cleared Round 1 🎉. In Round 2, we were tested on a mix of MCQs and Automata programming questions. To help those preparing, I’m sharing some of the programming questions that came up for me and a few my friend encountered during this round. You can use them to practice and get a feel for the kind of questions asked. 🚀
Round 2 Overview
MCQs: These covered concepts from basic programming, data structures, and problem-solving. Be sure to brush up on logic, arrays, and basic algorithms.
Automata (Programming Questions): We had to solve two coding problems. Below are detailed explanations of the questions.
Programming Questions
Question 1: Sum of Odd Digits
Problem Statement:
Given a positive integer, calculate the sum of its odd digits.
Example:
Input: 27283
Output: 10 (7 + 3)
Approach:
Extract each digit of the number.
Check if the digit is odd.
Add all odd digits and return the sum.
Test Cases:
Input:
13579→ Output:25Input:
24680→ Output:0
Question 2: Rearrange Array Elements
Problem Statement:
Given an array of integers, rearrange it so that all even numbers appear before all odd numbers, maintaining their relative order.
Example:
Input: [13, 14, 15, 20]
Output: [14, 20, 13, 15]
Approach:
Separate the even and odd numbers while maintaining their relative order.
Combine the even numbers first, followed by odd numbers.
Test Cases:
Input:
[2, 4, 6, 1, 3, 5]→ Output:[2, 4, 6, 1, 3, 5]Input:
[1, 3, 5, 7]→ Output:[1, 3, 5, 7]
Question 3: Repeated Digits in a Number
Problem Statement:
Given a number, count how many digits appear more than once.
Example:
Input: 1253532
Output: 3 (Digits 2, 3, and 5 are repeated)
Approach:
Count the occurrences of each digit.
Return the count of digits that appear more than once.
Test Cases:
Input:
1112233→ Output:3Input:
12345→ Output:0
Question 4: Multiply All Digits in a Number
Problem Statement:
Given a positive integer, calculate the product of all its digits.
Example:
Input: 123
Output: 6 (1 × 2 × 3)
Approach:
Extract each digit of the number.
Multiply all the digits together.
Test Cases:
Input:
234→ Output:24Input:
101→ Output:0
Question 5: Fibonacci Series
Problem Statement:
Generate the Fibonacci series up to a given number of terms.
Example:
Input: 5
Output: [0, 1, 1, 2, 3]
Approach:
Start with the first two terms,
0and1.Continue adding terms until the desired number is reached.
Test Cases:
Input:
7→ Output:[0, 1, 1, 2, 3, 5, 8]Input:
1→ Output:[0]
Question 6: Find the Nth Smallest Element in a List
Problem Statement:
Given a list of integers and a number nn, find the nn-th smallest element.
Example:
Input: ([7, 10, 4, 3, 20, 15], 3)
Output: 7
Approach:
Sort the array in ascending order.
Pick the nn-th smallest element.
Test Cases:
Input:
([1, 3, 2, 4, 5], 2)→ Output:2Input:
([100, 200, 300, 400], 1)→ Output:100
Tips for Solving Automata Questions
Practice Speed: Time is limited, so work on optimizing your solutions. Avoid overcomplicating logic.
Write Clean Code: Indentation and clarity matter, as these tests are often auto-evaluated.
Edge Cases: Always test your code for edge cases, such as empty arrays, single-digit numbers, or large inputs.
Brush Up Basics: Topics like arrays, strings, and simple algorithms are frequently tested.
Wrapping Up
These questions will give you a good start in preparing for Tech Mahindra placements or any similar tests. Practice them, understand the logic behind each, and work on your efficiency.
If you’re preparing for your placements, best of luck! Feel free to reach out if you have any questions or want help with more practice problems. Let’s crack those interviews together! 🚀
Happy coding! 😊




