Professional Documents
Culture Documents
PDF 3
PDF 3
https://www.youtube.com/c/PappuCareerGuide/
1. Gp ( Done)
7. Numbers Puzzle
9. Moving Apples
11. Penalty
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-13th-april-exam.html 3/28
7/2/22, 11:46 PM Tech M 2nd Round Non-SDE Complete All Asked Coding Repeated Questions Complete Analysis With Solution
#include <bits/stdc++.h>
int main() {
double second_term;
double third_term;
int n;
cin>>second_term>>third_term>>n;
double a = second_term/r;
return 0;
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-13th-april-exam.html 4/28
7/2/22, 11:46 PM Tech M 2nd Round Non-SDE Complete All Asked Coding Repeated Questions Complete Analysis With Solution
https://t.me/techmahindra2021crack
In Python
Coming Soon.....
In C
Coming Soon.....
https://www.youtube.com/c/PappuCareerGuide/
In C++
#include <bits/stdc++.h>
int main() {
// a#b#c
// ex
// 10 - binary- 1 0 1 0
// output 2#1#3
int n;
Join Now
cin>>n;
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-13th-april-exam.html 5/28
7/2/22, 11:46 PM Tech M 2nd Round Non-SDE Complete All Asked Coding Repeated Questions Complete Analysis With Solution
int c=-1;
int i=0;
// solved by Pappu Career Guide
{
if(n&1)
{
a++;
if(b==-1)
{
b=i;
}
c=i;
}
i++;
Join Now
n=n>>1; //right shift
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-13th-april-exam.html 6/28
7/2/22, 11:46 PM Tech M 2nd Round Non-SDE Complete All Asked Coding Repeated Questions Complete Analysis With Solution
}
Freshersocjob.com - Latest Jobs for Freshers and Interview Prepparation
In Python
n=int(input())
bi=bin(n)
bi=int(bi[2:])
x=[]
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
Join Now
print(a,b,c,sep="#")
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-13th-april-exam.html 7/28
7/2/22, 11:46 PM Tech M 2nd Round Non-SDE Complete All Asked Coding Repeated Questions Complete Analysis With Solution
In C
Freshersocjob.com - Latest Jobs for Freshers and Interview Prepparation
Coming Soon.....
https://t.me/techmahindra2021crack
#include <bits/stdc++.h>
string helper(string s)
{
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="";
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-13th-april-exam.html 8/28
7/2/22, 11:46 PM Tech M 2nd Round Non-SDE Complete All Asked Coding Repeated Questions Complete Analysis With Solution
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
Join Now
Coming Soon.....
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-13th-april-exam.html 9/28
7/2/22, 11:46 PM Tech M 2nd Round Non-SDE Complete All Asked Coding Repeated Questions Complete Analysis With Solution
#include <bits/stdc++.h>
using namespace std;
// Solved By Pappu Kumar (Coder Guy)
string helper(string s)
{
string result = ""; // answer store string
{
char ch = char((s[i] + 3 - 97)%26 + 97);
result+=ch;
}
return result;
}
int main() {
string s;
cin>>s;
Join Now
cout<<helper(s);
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-13th-april-exam.html 10/28
7/2/22, 11:46 PM Tech M 2nd Round Non-SDE Complete All Asked Coding Repeated Questions Complete Analysis With Solution
}
https://t.me/techmahindra2021crack
In C
Coming Soon.....
In Python
Coming Soon.....
https://t.me/placemate
5. Number of Decodings
def numDecodings(s):
if not s:
return 0
dp[0] = 1
Join Now
# One step jump
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-13th-april-exam.html 11/28
7/2/22, 11:46 PM Tech M 2nd Round Non-SDE Complete All Asked Coding Repeated Questions Complete Analysis With Solution
dp[i] += dp[i - 1]
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.....
#include <bits/stdc++.h>
{
Join Now
https://t.me/freshersoffcampjobs
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-13th-april-exam.html 12/28
7/2/22, 11:46 PM Tech M 2nd Round Non-SDE Complete All Asked Coding Repeated Questions Complete Analysis With Solution
int dp[s1.length()+1][s2.length()+1];
Freshersocjob.com - Latest Jobs for Freshers and Interview Prepparation
https://t.me/placemate
for(int i=0;i<=s1.length();i++)
{
for(int j=0;j<s2.length();j++)
{
dp[i][j]=0;
}
}
https://t.me/freshersoffcampjobs
for(int i=1;i<=s1.length();i++)
{
for(int j=1;j<=s2.length();j++)
{
if(s1[i-1]==s2[j-1])
{
dp[i][j]=1+dp[i-1][j-1];
}
else
Join Now
{
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-13th-april-exam.html 13/28
7/2/22, 11:46 PM Tech M 2nd Round Non-SDE Complete All Asked Coding Repeated Questions Complete Analysis With Solution
dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
Freshersocjob.com - Latest Jobs for Freshers and Interview Prepparation
}
}
}
return dp[s1.length()][s2.length()];
int main() {
string s1;
string s2;
cin>>s1>>s2;
cout<<helper(s1,s2);
https://t.me/freshersoffcampjobs
return 0;
#include<stdio.h>
Join Now
#include <stdlib.h>
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-13th-april-exam.html 14/28
7/2/22, 11:46 PM Tech M 2nd Round Non-SDE Complete All Asked Coding Repeated Questions Complete Analysis With Solution
int temp;
temp = *x;
*x = *y;
*y = temp;
int i, j;
for(i=0;i<n-1;i++){
swap(&arr[j], &arr[j+1]);
}
}
}
int i;
for(i=0;i<n;i++){
Join Now
printf("%d \n", arr[i]);
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-13th-april-exam.html 15/28
7/2/22, 11:46 PM Tech M 2nd Round Non-SDE Complete All Asked Coding Repeated Questions Complete Analysis With Solution
}
Freshersocjob.com - Latest Jobs for Freshers and Interview Prepparation
https://t.me/freshersoffcampjobs
int sum=0;
for(int i=n-1;i>0;--i){
sum += abs(arr[i]-arr[i-1]);
}
printf("%d",sum);
}
int main(){
BubbleSort(arr, n);
//Display(arr,n);
AbsValue(arr,n);
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-13th-april-exam.html 16/28
7/2/22, 11:46 PM Tech M 2nd Round Non-SDE Complete All Asked Coding Repeated Questions Complete Analysis With Solution
https://t.me/freshersoffcampjobs
9. Moving Apples
Join Now
https://t.me/techmahindra2021crack
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-13th-april-exam.html 17/28
7/2/22, 11:46 PM Tech M 2nd Round Non-SDE Complete All Asked Coding Repeated Questions Complete Analysis With Solution
def inFixToPostFix():
inFix = '3*(x+1)-2/2'
postFix = ''
s = Stack()
for c in inFix:
if c in "0123456789x":
postFix += c
elif c in "+-":
if s.isEmpty():
s.push(c)
s.push(c)
elif c in "*/":
if s.isEmpty():
s.push(c)
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-13th-april-exam.html 18/28
7/2/22, 11:46 PM Tech M 2nd Round Non-SDE Complete All Asked Coding Repeated Questions Complete Analysis With Solution
elif c == "(":
Freshersocjob.com - Latest Jobs for Freshers and Interview Prepparation
s.push(c)
elif c == ")":
postFix += s.pop()
s.pop()
else:
print("Error")
print(postFix)
return postFix
https://t.me/techmahindra2021crack
pappu5
#include <bits/stdc++.h>
int penalty = 0;
Join Now
{
}
return penalty;
int main() {
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++)
{
cin>>arr[i];
}
cout<<helper(n, arr);
return 0;
https://t.me/techmahindra2021crack
}
Join Now
#include <stdio.h>
if (a == 0)
return b;
if (gcd(i, n) == 1)
result++;
return result;
int main()
{
Join Now
int n;
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-13th-april-exam.html 21/28
7/2/22, 11:46 PM Tech M 2nd Round Non-SDE Complete All Asked Coding Repeated Questions Complete Analysis With Solution
return 0;
pappu4
def remainder(st) :
ln = len(st)
rem = 0
rem = num % 11
return rem
st = "3435346456547566345436457867978"
print(remainder(st))