Tech Mahindra 2nd Round Non-SDE All Asked Coding Repeated Questions with Solution | Non-SDE Tech & Psychometric Assessment (1A/1B/1C)

 


Tech Mahindra 2nd Round 13th April Exam Shifts All Coding Question with Solution
Tech Mahindra 2nd Round 13th April Exam Shifts All Coding Question with Solution


Tech Mahindra 2nd Round 12th to 15th April Exam Shifts All Coding Question with Solution | Non-SDE Tech Technical & NonTechnical 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 Technical & Non-Technical All Repeated Questions SOLUTIONS:


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;

}


In Python

Coming Soon.....

In C

Coming Soon.....

2. BitWise Operation Question with Solution:

In C++

// solved by Pappu Kumar Guide

#include <bits/stdc++.h>

using namespace std;

int main() {

// a#b#c
// ex 
// 10 - binary- 1 0 1 0
// output 2#1#3

int n;

cin>>n;

int a=0; // most

int b=-1; // least

int c=-1;

int i=0;
// solved by Pappu Career Guide

// performing bit marking
while(n>0)

{
    if(n&1)

    {
        a++;

        if(b==-1)

        {

            b=i;
        }

        c=i;
    }

    i++;

    n=n>>1; //right shift
}

cout<< to_string(a)<<"#" << to_string(b) <<"#" << to_string(c);
// solved by Pappu Kumar Guide
return 0;

}

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;
}

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;


}

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

    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;

        }

    }

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()];

}

int main() {

    string s1;

    string s2;


    cin>>s1>>s2;

    cout<<helper(s1,s2);

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);

}

One More Solution of Number of Puzzle



8. Longest Increasing Subsequence Solution in Python

// Solved By Pappu Career Guide

Tech Mahindra 2nd Round 132th April Exam Shifts All Sections Question with Solution
https://t.me/freshersoffcampjobs
9. Moving Apples

// Solved By Pappu Career Guide

Tech Mahindra 2nd Round 132th April Exam Shifts All Sections Question with Solution

https://t.me/techmahindra2021crack

10. inFixToPostFix Solution in Python
// Solved By Pappu Career Guide

def inFixToPostFix():

inFix = '3*(x+1)-2/2'

postFix = ''

s = Stack()

for c in inFix:

    # if elif chain for anything that c can be

    if c in "0123456789x":

        postFix += c

    elif c in "+-":

        if s.isEmpty():

            s.push(c)

        elif s.top() =='(':

            s.push(c)

    elif c in "*/":

        if s.isEmpty():

            s.push(c)

        elif s.top() in "+-(":

            s.push(c)

    elif c == "(":

        s.push(c)

    elif c == ")":

        while s.top() is not '(':

            postFix += s.pop()

        s.pop()

    else:

        print("Error")

print(postFix)

return postFix

https://t.me/techmahindra2021crack

11. Penalty Solution in C++

// Solved By Pappu Career Guide

#include <bits/stdc++.h>

using namespace std;

int helper(int n, int arr[])

{

    int penalty = 0;

    sort(arr, arr+n); // inbuild method foro sort the array

    for(int i=1;i<n;i++) // look through all the element in the array

    {

        penalty+=abs(arr[i]-arr[i-1]);  // adding the adjecent element in a penalty variables

    }

    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

}

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;

}

pappu4

13. Next Number Generator in C++

// Solved By Pappu Career Guide




14. Next Number Element in C++

// Solved By Pappu Career Guide

15. Maximu Subarray in C++

// Solved By Pappu Career Guide

16. Minimise a String in C++

// Solved By Pappu Career Guide

17. Dubai Airport in C++

// Solved By Pappu Career Guide

18. Possible Decodings in C++

// Solved By Pappu Career Guide

19. Longest Decreasing Subsequence in C++

// Solved By Pappu Career Guide




20. Longest Palindromic subsequence in C++

// Solved By Pappu Career Guide




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))





22. Roots of the Quadratic Equation Solution

// Solved By Pappu Career Guide

 import static java.lang.Math.*;  

public class Main  

{  

https://t.me/freshersoffcampjobs

static void calculateRoots(int a, int b, int c)  

{  


if (a == 0)   

{  

System.out.println("The value of a cannot be 0.");  

return;  

}  


int d = b * b - 4 * a * c;  

double sqrtval = sqrt(abs(d));  

if (d > 0)   

{  

System.out.println("The roots of the equation are real and different. \n");  

System.out.println((double)(-b + sqrtval) / (2 * a) + "\n"+ (double)(-b - sqrtval) / (2 * a));  

}  

else if (d == 0)   

{  

System.out.println("The roots of the equation are real and same. \n");  

System.out.println(-(double)b / (2 * a) + "\n"+ -(double)b / (2 * a));  

}  

else   

{  

System.out.println("The roots of the equation are complex and different. \n");  

System.out.println(-(double)b / (2 * a) + " + i"+ sqrtval + "\n"+ -(double)b / (2 * a)+ " - i" + sqrtval);  

}  

}  

https://t.me/freshersoffcampjobs

public static void main(String args[])  

{  

int a = 1, b = -2, c = -3;      

calculateRoots(a, b, c);  

}  

}

23. Maximum Subarray Solution

// Solved By Pappu Career Guide

class Solution(object):

   def maxSubArray(self, nums):

      """

      :type nums: List[int]

      :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]

ob1 = Solution()

print(ob1.maxSubArray(nums))

24. Number of Selective Arrangement

// Solved By Pappu Career Guide

 




25. The Cuckoo Sequent Solution

// Solved By Pappu Career Guide

How To for Download All Section Non-SDE Tech With Coding Question with solution Complete in One PDF:  
 
All candidates All Section Non-SDE Tech & Psychometric Assessment (1A/1B/1C) and Coding solution Complete in One PDF download here:

Join Our Whats App Group

Step#1: Go to the above link, Join Our What's App Group.

Note: If Already Joined, Directly Apply Through Step#3.

Step#3: Apply Link: Click Below Link To Apply

Download Updated* Link: Click here (PDF Link)

Note: Download Now Complete PDF Files.

Also, Read More about this: 

Also, apply for other jobs,

TCS March Latest NQT Interview Experience 2021


Tips to Follow to Crack Tech Mahindra Exam 2021

CTS - Cognizant 96 Important Interview Questions 2021

TCS Ninja and Digital 2021 All Interview Questions

Hexaware technical interview 2021 

Stay tuned with www.freshersocjob.com to receive more such updates on recruitment. Join our Telegram Channel and Join our WhatsApp Group To get Instant updates for All Recruitment Internships and Off-Campus of 2021 Pass-Out Batch and Other Batch.


Comments