Professional Documents
Culture Documents
https://www.youtube.com/c/PappuCareerGuide/
1. Gp ( Done)
7. Numbers Puzzle
9. Moving Apples
11. Penalty
Join Now
17. Dubai Airport
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-non-sde-all-asked-coding-questions-with-solution.html 3/38
7/2/22, 11:59 PM Tech Mahindra 2nd Round Non-SDE All Asked Coding Repeated Questions with Solution | Non-SDE Tech & Psychometric A…
#include <bits/stdc++.h>
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-non-sde-all-asked-coding-questions-with-solution.html 4/38
7/2/22, 11:59 PM Tech Mahindra 2nd Round Non-SDE All Asked Coding Repeated Questions with Solution | Non-SDE Tech & Psychometric A…
int main() {
Freshersocjob.com - Latest Jobs for Freshers and Interview Prepparation
double second_term;
double third_term;
int n;
cin>>second_term>>third_term>>n;
double a = second_term/r;
return 0;
https://t.me/techmahindra2021crack
In Python
Coming Soon.....
In C
Coming Soon.....
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-non-sde-all-asked-coding-questions-with-solution.html 5/38
7/2/22, 11:59 PM Tech Mahindra 2nd Round Non-SDE All Asked Coding Repeated Questions with Solution | Non-SDE Tech & Psychometric A…
In C++
#include <bits/stdc++.h>
int main() {
// a#b#c
// ex
// 10 - binary- 1 0 1 0
// output 2#1#3
int n;
cin>>n;
int c=-1;
int i=0;
// solved by Pappu Career Guide
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-non-sde-all-asked-coding-questions-with-solution.html 6/38
7/2/22, 11:59 PM Tech Mahindra 2nd Round Non-SDE All Asked Coding Repeated Questions with Solution | Non-SDE Tech & Psychometric A…
{
a++;
if(b==-1)
{
b=i;
}
c=i;
}
i++;
In Python
Join Now
n=int(input())
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-non-sde-all-asked-coding-questions-with-solution.html 7/38
7/2/22, 11:59 PM Tech Mahindra 2nd Round Non-SDE All Asked Coding Repeated Questions with Solution | Non-SDE Tech & Psychometric A…
bi=bin(n)
Freshersocjob.com - Latest Jobs for Freshers and Interview Prepparation
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
print(a,b,c,sep="#")
In C
Coming Soon.....
https://t.me/techmahindra2021crack
#include <bits/stdc++.h>
Join Now
{
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="";
{
char ch = 97+i; // add the value of
ASCII value of i = 1 - taking b
result+=ch;
result+=to_string(arr[i]);
}
}
return result;
Join Now
https://t.me/techmahindra2021crack
}
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-non-sde-all-asked-coding-questions-with-solution.html 9/38
7/2/22, 11:59 PM Tech Mahindra 2nd Round Non-SDE All Asked Coding Repeated Questions with Solution | Non-SDE Tech & Psychometric A…
string s;
cin>>s;
cout<<helper(s);
return 0;
In Python
Coming Soon.....
In C
Coming Soon.....
#include <bits/stdc++.h>
using namespace std;
// Solved By Pappu Kumar (Coder Guy)
string helper(string s)
{ Join Now
{
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
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-non-sde-all-asked-coding-questions-with-solution.html 11/38
7/2/22, 11:59 PM Tech Mahindra 2nd Round Non-SDE All Asked Coding Repeated Questions with Solution | Non-SDE Tech & Psychometric A…
https://t.me/placemate
Freshersocjob.com - Latest Jobs for Freshers and Interview Prepparation
5. Number of Decodings
def numDecodings(s):
if not s:
return 0
dp[0] = 1
dp[i] += dp[i - 1]
dp[i] += dp[i - 2]
return dp[len(s)]
https://t.me/techmahindra2021crack
Join Now
s=input()
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-non-sde-all-asked-coding-questions-with-solution.html 12/38
7/2/22, 11:59 PM Tech Mahindra 2nd Round Non-SDE All Asked Coding Repeated Questions with Solution | Non-SDE Tech & Psychometric A…
print(numDecodings(s))
Freshersocjob.com - Latest Jobs for Freshers and Interview Prepparation
In C
Coming Soon.....
In c++
Coming Soon.....
#include <bits/stdc++.h>
https://t.me/freshersoffcampjobs
int dp[s1.length()+1][s2.length()+1];
https://t.me/placemate
for(int i=0;i<=s1.length();i++)
{
for(int j=0;j<s2.length();j++)
{
dp[i][j]=0;
Join Now
}
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-non-sde-all-asked-coding-questions-with-solution.html 13/38
7/2/22, 11:59 PM Tech Mahindra 2nd Round Non-SDE All Asked Coding Repeated Questions with Solution | Non-SDE Tech & Psychometric A…
}
Freshersocjob.com - Latest Jobs for Freshers and Interview Prepparation
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
{
dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
}
}
}
return dp[s1.length()][s2.length()];
Join Now
int main() {
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-non-sde-all-asked-coding-questions-with-solution.html 14/38
7/2/22, 11:59 PM Tech Mahindra 2nd Round Non-SDE All Asked Coding Repeated Questions with Solution | Non-SDE Tech & Psychometric A…
string s1;
Freshersocjob.com - Latest Jobs for Freshers and Interview Prepparation
string s2;
cin>>s1>>s2;
cout<<helper(s1,s2);
https://t.me/freshersoffcampjobs
return 0;
#include<stdio.h>
#include <stdlib.h>
int temp;
temp = *x;
*x = *y;
*y = temp;
Join Now
int i, j;
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-non-sde-all-asked-coding-questions-with-solution.html 15/38
7/2/22, 11:59 PM Tech Mahindra 2nd Round Non-SDE All Asked Coding Repeated Questions with Solution | Non-SDE Tech & Psychometric A…
for(i=0;i<n-1;i++){
Freshersocjob.com - Latest Jobs for Freshers and Interview Prepparation
swap(&arr[j], &arr[j+1]);
}
}
}
int i;
for(i=0;i<n;i++){
}
https://t.me/freshersoffcampjobs
int sum=0;
for(int i=n-1;i>0;--i){
sum += abs(arr[i]-arr[i-1]);
Join Now
}
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-non-sde-all-asked-coding-questions-with-solution.html 16/38
7/2/22, 11:59 PM Tech Mahindra 2nd Round Non-SDE All Asked Coding Repeated Questions with Solution | Non-SDE Tech & Psychometric A…
printf("%d",sum);
Freshersocjob.com - Latest Jobs for Freshers and Interview Prepparation
}
int main(){
BubbleSort(arr, n);
//Display(arr,n);
AbsValue(arr,n);
Join Now
https://www.youtube.com/c/PappuCareerGuide/
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-non-sde-all-asked-coding-questions-with-solution.html 17/38
7/2/22, 11:59 PM Tech Mahindra 2nd Round Non-SDE All Asked Coding Repeated Questions with Solution | Non-SDE Tech & Psychometric A…
Freshersocjob.com
- Latest Jobs for Freshers and Interview Prepparation
https://t.me/freshersoffcampjobs
9. Moving Apples
Join Now
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-non-sde-all-asked-coding-questions-with-solution.html 18/38
7/2/22, 11:59 PM Tech Mahindra 2nd Round Non-SDE All Asked Coding Repeated Questions with Solution | Non-SDE Tech & Psychometric A…
https://t.me/techmahindra2021crack
def inFixToPostFix():
inFix = '3*(x+1)-2/2'
postFix = ''
s = Stack()
for c in inFix:
Join Now
# if elif chain for anything that c can be
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-non-sde-all-asked-coding-questions-with-solution.html 19/38
7/2/22, 11:59 PM Tech Mahindra 2nd Round Non-SDE All Asked Coding Repeated Questions with Solution | Non-SDE Tech & Psychometric A…
if c in "0123456789x":
Freshersocjob.com - Latest Jobs for Freshers and Interview Prepparation
postFix += c
elif c in "+-":
if s.isEmpty():
s.push(c)
s.push(c)
elif c in "*/":
if s.isEmpty():
s.push(c)
s.push(c)
elif c == "(":
s.push(c)
elif c == ")":
postFix += s.pop()
s.pop()
else:
Join Now
print("Error")
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-non-sde-all-asked-coding-questions-with-solution.html 20/38
7/2/22, 11:59 PM Tech Mahindra 2nd Round Non-SDE All Asked Coding Repeated Questions with Solution | Non-SDE Tech & Psychometric A…
print(postFix)
Freshersocjob.com - Latest Jobs for Freshers and Interview Prepparation
return postFix
https://t.me/techmahindra2021crack
#include <bits/stdc++.h>
int penalty = 0;
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-non-sde-all-asked-coding-questions-with-solution.html 21/38
7/2/22, 11:59 PM Tech Mahindra 2nd Round Non-SDE All Asked Coding Repeated Questions with Solution | Non-SDE Tech & Psychometric A…
}
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>
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-non-sde-all-asked-coding-questions-with-solution.html 22/38
7/2/22, 11:59 PM Tech Mahindra 2nd Round Non-SDE All Asked Coding Repeated Questions with Solution | Non-SDE Tech & Psychometric A…
if (a == 0)
return b;
if (gcd(i, n) == 1)
result++;
return result;
int main()
int n;
return 0;
Freshersocjob.com - Latest Jobs for Freshers and Interview Prepparation
pappu4
https://www.youtube.com/c/PappuCareerGuide/
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-non-sde-all-asked-coding-questions-with-solution.html 24/38
7/2/22, 11:59 PM Tech Mahindra 2nd Round Non-SDE All Asked Coding Repeated Questions with Solution | Non-SDE Tech & Psychometric A…
https://www.youtube.com/c/PappuCareerGuide/
Join Now
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-non-sde-all-asked-coding-questions-with-solution.html 25/38
7/2/22, 11:59 PM Tech Mahindra 2nd Round Non-SDE All Asked Coding Repeated Questions with Solution | Non-SDE Tech & Psychometric A…
https://www.youtube.com/c/PappuCareerGuide/
def remainder(st) :
ln = len(st)
rem = 0
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-non-sde-all-asked-coding-questions-with-solution.html 26/38
7/2/22, 11:59 PM Tech Mahindra 2nd Round Non-SDE All Asked Coding Repeated Questions with Solution | Non-SDE Tech & Psychometric A…
rem = num % 11
Freshersocjob.com - Latest Jobs for Freshers and Interview Prepparation
return rem
st = "3435346456547566345436457867978"
print(remainder(st))
https://www.youtube.com/c/PappuCareerGuide/
Join Now
https://www.youtube.com/c/PappuCareerGuide/
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-non-sde-all-asked-coding-questions-with-solution.html 27/38
7/2/22, 11:59 PM Tech Mahindra 2nd Round Non-SDE All Asked Coding Repeated Questions with Solution | Non-SDE Tech & Psychometric A…
{
https://t.me/freshersoffcampjobs
{
if (a == 0)
{
return;
}
int d = b * b - 4 * a * c;
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-non-sde-all-asked-coding-questions-with-solution.html 28/38
7/2/22, 11:59 PM Tech Mahindra 2nd Round Non-SDE All Asked Coding Repeated Questions with Solution | Non-SDE Tech & Psychometric A…
{
Freshersocjob.com - Latest Jobs for Freshers and Interview Prepparation
System.out.println((double)(-b + sqrtval) / (2 * a) +
"\n"+ (double)(-b - sqrtval) / (2 * a));
}
else if (d == 0)
{
System.out.println(-(double)b / (2 * a) + "\n"+ -
(double)b / (2 * a));
}
else
{
}
}
https://t.me/freshersoffcampjobs
{
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-non-sde-all-asked-coding-questions-with-solution.html 29/38
7/2/22, 11:59 PM Tech Mahindra 2nd Round Non-SDE All Asked Coding Repeated Questions with Solution | Non-SDE Tech & Psychometric A…
calculateRoots(a, b, c);
}
class Solution(object):
"""
:rtype: int
"""
dp = [0 for i in range(len(nums))]
dp[0] = nums[0]
for i in range(1,len(nums)):
dp[i] = max(dp[i-1]+nums[i],nums[i])
#print(dp)
return max(dp)
nums = [-2,1,-3,7,-2,2,1,-5,4]
Join Now
ob1 = Solution()
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-non-sde-all-asked-coding-questions-with-solution.html 30/38
7/2/22, 11:59 PM Tech Mahindra 2nd Round Non-SDE All Asked Coding Repeated Questions with Solution | Non-SDE Tech & Psychometric A…
print(ob1.maxSubArray(nums))
Freshersocjob.com - Latest Jobs for Freshers and Interview Prepparation
https://www.youtube.com/c/PappuCareerGuide/
Join Now
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-non-sde-all-asked-coding-questions-with-solution.html 31/38
7/2/22, 11:59 PM Tech Mahindra 2nd Round Non-SDE All Asked Coding Repeated Questions with Solution | Non-SDE Tech & Psychometric A…
Join Now
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-non-sde-all-asked-coding-questions-with-solution.html 32/38
7/2/22, 11:59 PM Tech Mahindra 2nd Round Non-SDE All Asked Coding Repeated Questions with Solution | Non-SDE Tech & Psychometric A…
https://www.youtube.com/c/PappuCareerGuide/
https://www.youtube.com/c/PappuCareerGuide/
Join Now
https://www.freshersocjob.com/2021/04/tech-mahindra-2nd-round-non-sde-all-asked-coding-questions-with-solution.html 33/38