You are on page 1of 15

Tech Mahindra 2nd Round Complete Exam Shifts All

Sections Question with Solution | Non-SDE Tech &


Psychometric Assessment (1A/1B/1C) Solved
by Pappu Career Guide

Tech Mahindra 2nd Round 12th April Exam Shifts Non-SDE


Tech All Sections Question with Solution

TECH MAHINDRA Non-SDE ALL CODING


SOLUTIONS:
https://www.youtube.com/c/PappuCareerGuide/

1. Gp ( Done)

2. Bitwise operation (Done)

3. Frequency Count (Done)

4. Caesar Cipher (Done)


5. Number of Decoding (Done)

6. Longest Common Subsequence

7. Numbers Puzzle

8. Longest Increasing Subsequence

9. Moving Apples

10. infix to postfix

11. Penalty

12. Euler’s Totient Function

13. Next Number Generator

14. Next Number Element

15. Maximum Subarray

16. Minimise a String

17. Dubai Airport

18. Possible Decodings

19. Longest Decreasing Subsequence

20. Longest Palindromic subsequence

21. Module 11 code

22. Roots of the Quadratic Equation

23. Maximum Subarray

24. Number of Selective Arrangement

25. The Cuckoo Sequent

26. Character Count


1. Geometric Progression Question with Solution:

Geometric Progression In C++

// Solved By Pappu Career Guide

#include <bits/stdc++.h>

using namespace std;

int main() {

double second_term;

double third_term;

int n;

cin>>second_term>>third_term>>n;

double r = third_term/second_term; //9/3=3

double a = second_term/r;

double nth_term = a * pow( r, n-1);

cout<<nth_term;

return 0;

https://t.me/techmahindra2021crack

In Python
Coming Soon.....
In C
Coming Soon.....
https://www.youtube.com/c/PappuCareerGuide/

2. BitWise Operation Question with Solution:


In C++

// solved by Pappu Kumar Guide

see Solution in Website

In Python

n=int(input())

bi=bin(n)

bi=int(bi[2:])

x=[]

// Solved By Pappu Career Guide

while(bi>0):

x.append(bi%10)

bi//=10

a=x.count(1)

b=x.index(1)

x.reverse()

c=len(x)-x.index(1)-1

print(a,b,c,sep="#")

In C
Coming Soon.....
https://t.me/techmahindra2021crack

3. Frequency Count Question with Solution:

Frequency Count In C++

// Solved By Pappu Career Guide


#include <bits/stdc++.h>

using namespace std;

string helper(string s)

// Solved By Pappu Kumar (Coder Guy)

{
int arr[26]={0}; // there are 26 alphabets
in the english char
for(int i=0;i<s.length();i++) // loop through
the input string
{
arr[s[i]-97]++; //
to come back with the 0 position

string result="";

for(int i=0;i<26;i++) // for character


count with loop
{
if(arr[i]>0) // if char is present

{
char ch = 97+i; // add the value of
ASCII value of i = 1 - taking b
result+=ch;

result+=to_string(arr[i]);

return result;
https://t.me/techmahindra2021crack
}

int main() {

string s;

cin>>s;

cout<<helper(s);

return 0;

}
In Python
Coming Soon.....
In C
Coming Soon.....

4. Caesar Cipher Question with Solution:

Caesar Cipher In C++

// Solved By Pappu Career Guide

#include <bits/stdc++.h>

using namespace std;


// Solved By Pappu Kumar (Coder Guy)

string helper(string s)
{
string result = ""; // answer store string

for(int i=0;i<s.length();i++) // loop through


the input string

{
char ch = char((s[i] + 3 - 97)%26 + 97);

result+=ch;

return result;

}
int main() {

string s;

cin>>s;

cout<<helper(s);
return 0;

}
https://t.me/techmahindra2021crack

In C
Coming Soon.....
In Python
Coming Soon.....
https://t.me/placemate
5. Number of Decodings
The solution in Python:
def numDecodings(s):

if not s:

return 0

dp = [0 for x in range(len(s) + 1)]

# base case initialization

dp[0] = 1

dp[1] = 0 if s[0] == "0" else 1 #(1)

for i in range(2, len(s) + 1):

# One step jump

if 0 < int(s[i-1:i]) <= 9: #(2)

dp[i] += dp[i - 1]

# Two step jump

if 10 <= int(s[i-2:i]) <= 26: #(3)

dp[i] += dp[i - 2]
return dp[len(s)]

https://t.me/techmahindra2021crack

s=input()

print(numDecodings(s))
In C

Coming Soon.....

In c++

Coming Soon.....

6. Longest Common Subsequence

// Solved By Pappu Career Guide


#include <bits/stdc++.h>

using namespace std;

string helper(string s1 , string s2)

https://t.me/freshersoffcampjobs

See Complete Solution in My Website

https://t.me/freshersoffcampjobs

return 0;

7. Numbers Puzzles Solution in C

// Solved By Pappu Career Guide


#include<stdio.h>

#include <stdlib.h>

void swap(int *x, int *y){


int temp;

temp = *x;

*x = *y;

*y = temp;

void BubbleSort( int arr[], int n ){

int i, j;

for(i=0;i<n-1;i++){

for (j = 0; j < n-i-1; j++){

if (arr[j] > arr[j+1]){

swap(&arr[j], &arr[j+1]);

int Display(int arr[], int n){

int i;

for(i=0;i<n;i++){

printf("%d \n", arr[i]);

https://t.me/freshersoffcampjobs

int AbsValue(int arr[],int n){

int sum=0;

for(int i=n-1;i>0;--i){

sum += abs(arr[i]-arr[i-1]);
}

printf("%d",sum);

int main(){

int arr[] = {3,2,1};

int n = sizeof(arr) / sizeof(arr[0]);

BubbleSort(arr, n);

//Display(arr,n);

AbsValue(arr,n);

8.Longest Increasing Subsequence Solution in


Python
// Solved By Pappu Career Guide

https://t.me/freshersoffcampjobs
9. Moving Apples
// Solved By Pappu Career Guide
https://t.me/techmahindra2021crack

10. infix to postfix Solution in Python


// Solved By Pappu Career Guide

See Solution in my Website

https://t.me/techmahindra2021crack
11. Penalty Solution in C++

// Solved By Pappu Career Guide


See in My Website

https://t.me/techmahindra2021crack

12. Euler’s Totient Function in C++

// Solved By Pappu Career Guide


#include <stdio.h>

int gcd(int a, int b)

if (a == 0)

return b;

return gcd(b % a, a);

int phi(unsigned int n)

unsigned int result = 1;

for (int i = 2; i < n; i++)

if (gcd(i, n) == 1)

result++;

return result;

int main()

int n;

for (n = 1; n <= 10; n++)

printf("phi(%d) = %d\n", n, phi(n));


return 0;

https://www.youtube.com/c/PappuCareerGuide/

13. Next Number Generator in C++

// Solved By Pappu Career Guide


see in my website

14. Next Number Element in C++

// Solved By Pappu Career Guide


see in my website

15. Maximu Subarray in C++

// Solved By Pappu Career Guide


see in my website

16. Minimise a String in C++

// Solved By Pappu Career Guide


see in my website

17. Dubai Airport in C++

// Solved By Pappu Career Guide


see in my website

18. Possible Decodings in C++

// Solved By Pappu Career Guide


see in my website

19. Longest Decreasing Subsequence in C++

// Solved By Pappu Career Guide


see in my website

20. Longest Palindromic subsequence in C++

// Solved By Pappu Career Guide


see in my website

21. module 11 in Python

// Solved By Pappu Career Guide


def remainder(st) :

ln = len(st)

rem = 0

for i in range(0, ln) :

num = rem * 10 + (int)(st[i])

rem = num % 11

return rem

st = "3435346456547566345436457867978"

print(remainder(st))

https://www.youtube.com/c/PappuCareerGuide/

22. Roots of the Quadratic Equation Solution

// Solved By Pappu Career Guide


See Solution in My Website

23. Maximum Subarray Solution

// Solved By Pappu Career Guide


See Solution in My Website

24. Number of Selective Arrangement

// Solved By Pappu Career Guide


See Solution in My Website

25. The Cuckoo Sequent

// Solved By Pappu Career Guide


See Solution in My Website

26. Character Count

// Solved By Pappu Career Guide


See Solution in My Website

★ Subscribe to us on YouTube for Campus Placement Preparation!! ★

★ Join our Telegram Channel for Instant job Updates !! ★

★ Follow us on Instagram for Interview Tips and Tricks!! ★

★ Follow us on Linked in for Referral Jobs Updates !! ★

★ Follow us on Facebook for Top MNCs Job Updates !! ★

★Follow us on Twitter for Latest Career and Jobs News!!★

You might also like