Mindtree Coding Test Papers (AMCAT AUTOMATA)

Mindtree Coding Technical Test Papers
Mindtree online coding test conducted by amcat, this Autonoma programming test consists of two coding questions which have to be solved with using any of the following languages C or C++ or Java. Selecting a particular language is completely our choice. Within 45 minutes of time, one has to run two programs successfully using the online compiler.

Here I am guessing you will get one easy question and one hard question, There may be chances of selection if one of the programs is running without any errors and giving the status of a test case is positive, and at least try to attempt for a second answer, Coding questions one will be pattern based another mainly a loop-based question.

Explore career possibilities


Mindtree Coding Test Placement Paper

Question:- Find a substring in a given string and replace it with another string?

Question:- Remove all the vowels from a given string using the concept of the pointer


Question:- Find the GCD of the two integers.

Answer:-
#include <iostream>
using namespace std;
int gcd_iter(int u, int v) 
{
  int t;
  while (v) 
  {
    t = u; 
    u = v; 
    v = t % v;
  }
  return u < 0 ? -u : u; 
}
int main()
{
  int n=3,m=6;
  int result=gcd_iter(n,m);
  cout<<result;
   return 0;
}


Question:- Print all the prime numbers which are below the given number separated by comma.

Question:- Write a function to return a sorted array after merging two unsorted arrays, the parameters will be two integer pointers for referencing arrays and two int variable, the length of arrays (Hint: use malloc() to allocate memory for 3rd array):


Pattern Question:-
For n=5
1
3*2
4*5*6
10*9*8*7
11*12*13*14*15
Answer:-
#include <iostream>
using namespace std;
int main()
{
   int n=5,num;
   num=1;
   int l=1;
   int k=num;
   for(int i=1;i<=n;i++)
   {
     k=num-1;
       for(int j=1;j<=num;j++)
       {
           if(j%2==0)
           cout<<"*";
           else
           {
               if(i%2==0)
               {      
               cout<<k+l-num+i;
               l++;
               k=k-2;
               }
              else
               cout<<l++;
           }
       }
       num=num+2;//the loop is going on as a prime number 1,3,5,7
       cout<<"\n";
   }
   return 0;
}



Pattern Question:-

For n=4, s=3
3
44
555
6666
6666
555
44
3



Pattern Question:-

1
22
333
4444
55555
4444
333
22
1

Pattern Question:-

To print the pattern like for n=3 the program should print
1 1 1 2 
3 2 2 2 
3 3 3 4
Answer :-
#include <iostream>
using namespace std;
int main()
{
   int n=3,c=n-1;
   for(int i=1;i<=n;i++)
   {
       if(i%2==0)
       cout<<c++;
       for(int j=1;j<=n;j++)
       {
           cout<<i;
       }
       if(i%2!=0)
       cout<<c++;
       cout<<"\n";
   }
   return 0;
}



Pattern Question:-

To print the trapezium pattern. for example , we have n=4 the output should be like
1*2*3*4*17*18*19*20
- -5*6*7*14*15*16
- - - -8*9*12*13
- - - - - -10*11
Answer:-
#include<iostream>
using namespace std;
int main(){
    int n=4,num=1,i=1,space=0,k=1,number=n;
    for(i=0;i<n;i++)
    {
        for(int j=1;j<=space;j++)
        {
            cout<<"-"; 
        }
        for(int m=1;m<2*n-space;m++)
        {
            if(m%2==0)
                cout<<"*";
            else
                cout<<num++;
        }
        cout<<"*";
         for(int l=1;l<2*n-space;l++)
        {
            if(l%2==0)
                cout<<"*";
            else
            {
                cout<<k+number*number;
        k++;
            }
        }
        number--;      
        space=space+2;
        cout<<endl;
    }
    return 0;
}

Previous Post Next Post