MindTree Latest Coding Questions with Solutions

MindTree Off Campus : Previously Asked coding Questions with Solutions(2021/22)

Mindtree is a good company for you to start your career, they provide very good training for new people. Working environment is good, co-workers are very nice, but salary and benefits is not that appealing.There is no bond, there is Service Agreement.Here in this blog we can discuss some: Mindtree Coding questions with Answers,Mindtree coding questions 2022,Mindtree coding questions in java,AMCAT coding questions ,Mindtree coding question 2022 2021 2020.

About MindTree :
Mindtree delivers digital transformation and technology services from ideation to execution, enabling Global 2000 clients to outperform the competition. “Born digital,” Mindtree takes an agile, collaborative approach to creating customized solutions across the digital value chain.

Training – Mindtree's work environment is suitable for freshers as they are given intense and precise training before starting their work. Freshers who are trained at Mindtree have more advantages than others. The training program is inclusive of learning the advanced and latest technologies in the IT industry. 

Interview & Assessment Process :-
  • Aptitude Test
  • Coding Test
  • Technical Screening
  • Technical Discussion
  • HR Interview

1st round:
1st round will be conducted through amcat. To get clear this round prepare well the amcat questions.Most of the questions will be repeated. But cutoff mark is high. In this round it consists of three sections. 1st-quants ,2nd verbal 3rd logical reasoning. Concentrate more on Quants ,imp topics are profit and loss,percentage,probability, permutation and combination ,time and work,average. My suggestion is work out previous years amcat questions it ll be more than enough to crack this round. 2nd section consists of verbal ability. Concentrate more on meaning and spot the errors .Don’t waste more time on reading passage as it consumes a lot of time. 3rd section will be logical reasoning, its a bit easy round if you are good logical thinker.

2nd round:
2nd round is automata. In this round you will be given 2 coding questions ,you have to get at least 1 output for a program. Mostly 1st question will be easy .You may get questions from pattern,prime number,gcd..etc . 2nd question will be bit difficult. So try to get partial output in both the programs.

3rd round:
This is technical hr round. To crack this round be confident,be relaxed ,always have a smile in your face. If you don’t know the answer tell him like i don’t know sir. He is ask some other question. Question like why mindtree? ,hobbies ? team member ? project? they will check what kind of answer you will give to them.

4th round:

They ask you some general questions like tell me about yourself, from hobbies you may get more questions,..always have smile in your face. be positive
Need More Questions ping me on Instagram : codingsolution75

In this article, we will be discussing some of the Mindtree Coding Questions asked in the previous recruitment tests.


MindTree Coding Questions with Solutions Here

Mintree Question 1 : Calculate Average

Write a program to find the average of the first P multiples of an integers N.The first line contains an integer, N, denoting the integer The next line contains an integer, P, denoting the number of multiple consider.
Input : 3 5
Output: 9
Explanation :
3 + 6 + 9 + 12 + 15 = 45
45/5 = 9
import java.util.Scanner;
public class MyClass {
        public static void main(String args[]) {  
            Scanner sc = new Scanner(System.in);  
            int p = sc.nextInt();
            int n = sc.nextInt();
            int sum =0;
            for(int i=1; i<=n; i++){
                sum+=p*i;
            }
            System.out.println(sum/n);
        }
}
If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.

Mintree Question 2 : Reverse the word in given string

Write a program to reverse the character in the individual String
Input - Hello World
Output -olleh dlroW

Solution

import java.util.Scanner;
public class MyClass {
    public static String rev(String str){
        String reverse = "";
        for(int i=str.length()-1; i>=0; i--)
           reverse+=str.charAt(i);
        return reverse;
    }
    public static void main(String args[]) {
      Scanner sc = new Scanner(System.in);
      String str = sc.nextLine();
      String[] word = str.split(" ");
      for(int i=0; i<word.length; i++){
         System.out.print(rev(word[i])+" ");
      }
    }
}
If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.

Mindtree Question 3 : Manually String split

How to Manually Spite String contains without using predefined function in java
import java.util.Scanner;
public class SplitMenual {
	public static String[] mysplit(String s, char ch) {
	  int size = 0;
	  int count = 0;
	  int first = 0;
	  int j = 0;
	  for (int k = 0; k < s.length(); k++) {
	     if (s.charAt(k) == ch) {
		   size++;
		 }
	   }
	   String[] last = new String[size + 1];
	   for (int i = 0; i < s.length(); i++) {
		 int temp = s.length();
         if (i == s.length() - 1) {
		    last[j] = s.substring(first, i + 1);
		 }
		 if (s.charAt(i) == ch) {
		   last[j] = s.substring(first, i);
		   j++;
		   first = i + 1;
		 }
	   }
	   return last;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
 	    String[] arr = mysplit(s,',');
 	    for(String a : arr) {
 		   System.out.println(a);
        }
	}

}
If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.

Mindtree Question 4: Binary Jump

import java.util.Scanner;
public class BinaryJump {
   public static int powerOfJump(String s) {
      int count = 1;
      int maxx = Integer.MIN_VALUE;
      char ch = s.charAt(s.length() - 1);
      for (int i = 0; i < s.length(); i++) {
	 if (s.charAt(i) == ch) {
	   if (count > maxx) {
	      maxx = count;
	   }
	   count = 1;
	}else
	  count++;
	}
	return maxx;
    }
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	String st = sc.nextLine();
	System.out.println(powerOfJump(st));
    }
}
If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.

Mindtree Question 5 : Dani and Cups

Dani has N cups that needs to be filled with soda and each cup has a different capacity of soda that it can hold.
Dani has a particulate of filling the cups. He chooses a certain amount, say M and fills all the cups with M liters of soda if the cup's capacity us less than M
It's given that Dani wants then sum of soda that held in the cups to be at least L, He also wants the least amount of soda to be wasted.
Your task is to tell Dani the smallest value of M that allowed him to meet the conditions given above. If no value of M meets the given condition , output -1.
Function Description :
N Integer The number of cupsM
L Integer The minimum amount to soda in the cups
x Integer array The capacity of the cups.
Return
The function must be return an Integer denoting the smallest value of M that Dani should check the amount of soda in the cups the at least L, and -1 if he can't choose such M.
import java.util.Arrays;
import java.util.Scanner;

public class Cup {
  public static int Solve(int k, int n, int[] arr) {
      int sum = 0;
        for(int i=0;i<n;i++) 
          sum+=arr[i];
        if(sum<k)return-1;
        else{
          Arrays.sort(arr);
          int x = k/n;
          int max = x;
          while(max < k){
            max = n * x++;
          }
        return x-1; 
        }
  }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int k =sc.nextInt();
    int n = sc.nextInt();
    int[] a =new int[k];
    for(int i=0; i<k;i++) {
      a[i] = sc.nextInt();
    }
    System.out.println(Solve(n, k, a));
  }
}
If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.

Mindtree Question 6: MIN/MAX Prime in array .

You are given an array of integer, arr of size array length . Find the absolute difference(i.e difference >=0 ) between the larges and smallest prime number present in array.
Notes:
1. if there are 1 or fewer prime number in arr, return 0
2. The array may contains positive and negative numbers. It is given that negative numbers are not prime.
3. 1 and 0 are not prime
4. A prime number is a number which is only divisible by itself and 1 (e.g 2,3,5,7,11,13...)
Function Description :
Complete the differenceMaxMinPrime function in the editor below. It has the following parameter(s):
Parameters Name: arr
Type: INTEGER ARRAY
Description: The array you are given
Return:The function must return an INTEGER denoting the positive difference between the maximum and minimum prime numbers in the array as specified in the problem statement.
Sample Cases
Input
5
5 16 22 5 3
Output 2
Explanation :
Largest prime number = 5
Smallest prime number = 3
Absolute difference = 2
Input
8
-3 22 -10 20 15 16 12 1
Output
0
Explanation:
In this array no prime number hence output is 0.

Solution

import java.util.Scanner;
public class MinMaxPrimeDifference {
  public static boolean isPrime(int num) {
	for (int i = 2; i < num / 2; i++) {
	  if (num % i == 0) {
		return false;
	   }
	}
	return true;
  }
  public static int minmaxAbsoluteDifference(int[] arr) {
	int min = Integer.MAX_VALUE;
	int max = 0;
	int c = 0;
	for (int i = 0; i < arr.length; i++) {
		if (arr[i] >= 2) {
		   if (isPrime(arr[i])) {
			  if (arr[i] > max) max = arr[i];
			  if (arr[i] <min) min = arr[i];
				c++;
		   }
		}
	}
	if (c != 0) return (int)(Math.abs(max - min));
	else return 0;	
  }
  public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int[] arr = new int[n];
	for (int i = 0; i < n; i++) {
		arr[i] = sc.nextInt();
	}
	System.out.println(minmaxAbsoluteDifference(arr));
  }
}

If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.

Mindtree Question 7: Alternative Consecutive Sum

When the sum of N consecutive even number (where each number being added to the sum is denoted by Ei,1<=i<=N) is either a prime pr an even number it is call Happpy number
Your are given an integer input X. white a program to find s1,s2,s3 and so on of N consecutive even Integer where value of N keeps Increasing by 1 You should continue this process until Ei <= X
Example:
X = 10
N=1 : 0 = 0
N=2 : 0+2=2
N=3 : 0+2+4=6
....
N=6 : 0+2+4+6+8+10 = 30
In this example, there are a total of 6 sums which are happy numbers.
Your task is to return the count of happy numbers amongst all the sums.
Note:
The first even numbers should ne taken as 0.
Function Description:
Complete the count function in the editor below. It has the following parameter(s):
Parameters Name : X
Type : Integer
Description : Denotes the upper bound of any integer that can be added to a combination.
Return : The function must be return an Integer denoting the total count of happy numbers for the given criteria.
Constraints: 1<=X<=105
Sample test case Input
2
Output
2
Input
34
Output
18

Solution

import java.util.Scanner;
public class AltternativeConsequtiveSum {
	public static int count(int x) {
		return (int)(x/2)+1;
	}
	public static void main(String[] args) {
	  Scanner sc = new Scanner(System.in);
	  int x = sc.nextInt();
	  System.out.println(count(x));
	}
}
If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.

Mindtree Question 8: Rearranging digits in an Integer

Rearrange Digits in an Integer:
You are given an array of positive integer arr, of size of array_length. your task is to find the number of special integer in arr. Its given that an integer num is consider a special integer. if its digit be rearrange in any way to produce an large then number.
Note:
431 is a special integer, as no other combination of its digit would produce an integer that is larger than 431.
312 is NOT a special number integer as you Could rearrange the digit as 321, which would be larger than 312.
Any single digit integer such as 5 is always a special integer.
Function Description :
Complete the numSpecial function in the below editor it has following parameter(s).
Parameters Name : arr
Type : INTEGER ARRAY
Description : The given array
Return : The function must return an INTEGER denoting the number of integer in an array whose digit cannot be rearrange to produce a large integer as special in the problem statement.
Constraints
1 <= array_length <= 105
1 <= arr[i] <= 105
Input Format For Custom Testing
The first line contains an integer, array_length denoting the number of elements of in arr.
Each line i of the array_length sub sequence line(Where 0 <= i <= array_length) contains an integer describing arr[i].
Sample Test Cases
Input
2
321
433
Output
2
Explanation
Both 321 and 433 are special, so output is 2.
Input
2
312
431
Output
1
Explanation
321 is not special, but 431 is special, so output is 1.

Solution

import java.util.Scanner;
public class RearrangeNumber {
	public static int rearrange(int a) {
		int b=0;
		for (int i=9;i>=0;i--)
		{
		int c=a;
		while (c>0)
		{
		    int d=c%10;             
		    if (d==i)
		    {
		        b=(b*10)+d;
		    }
		    c/=10;                
		}               
		}
		return b;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for(int i=0; i<n; i++) arr[i] = sc.nextInt();       
		int x=0;
	    for(int i=0; i<n; i++) {
	    	if(arr[i] == rearrange(arr[i])) x++;
	    }	
	    System.out.println(x);
	}
}
If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.

Mindtree Question 9: Sherlock Number

Sherlock numbers is a number in which the sum of its digits is an even number.
You are the given an integer input N. Your task is to return the count of all the Sherlock numbers between 1 to N(0 <= Sherlock number <= N)
Function Description:
Complete the count function in the editor below. Its has the following parameter(s):
Parameter name : N
Type : Integer
Description : Denotes the integer number.
Return : Function return must integer number
Constraints:
1 <= N <= 105
Input Format For Custom Testing: The first line contains an integer N, denoting the upper bound of the given range.
Sample Cases:
Input
518
Output
260
Explanation:
Between 0 to 518, there are 260 Sherlock numbers.
Input
318
Output
160
Explanation:
Between 0 to 318 , there are 160 Sherlock numbers.
import java.util.Scanner;
public class Sherlock {
    public static int count(int n){
       if (n % 2 == 0) return ((int) (n / 2) + 1);
	   else  return ((int) (n / 2));
    }
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		System.out.println(count(n));
	}
}
If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.

MindTree Question 10 : A in String

You are the given an Integer N and string array B. as the input where N denotes the length of B. Write a program to return the count all the elements in B having 'A' or 'a' as their first character.
Function Description
Complete the check function in the editor below. It has the following parameter(s):
Parameter Name : B
Type : String array
Description : Denotes the input Strings of varying lengths.
Return : The function must return an INTEGER denoting the count of all the elements in B with 'A' or 'a' as the first character.
Constraints:
1 <= N <= 50
1 <= len(B[i]) <= 50
Input Format For Custom Testing
The first line contains an integer , N denoting the number of elements in B.
Each line i of the N sub-sequence line (where 0 <= i < N) contains a string described Bi.
Sample Cases:
Input
6
snotitly
typhgilos
vagaris
addresess
assload
tpndo
Output
2
Explanation:
There are 2 elements having 'a' or 'A' as the first character.
import java.util.Scanner;
public class AinString {
	public static int CountA(String[] arr) {
		int c =0;
		for(String str : arr) {
			if(str.charAt(0) =='A' || str.charAt(0) =='a') c++;
		}
		return c;
	}
	public static void main(String[] args) {
		  Scanner sc= new Scanner(System.in);
		  int n = sc.nextInt();sc.nextLine();
		  String[] arr = new String[n];
		  for(int i=0; i<n; i++) arr[i] = sc.nextLine();
          System.out.println(CountA(arr));
	}
}

If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.

MindTree Question 11 : Product with Successor

import java.util.Scanner;
public class ProductWIthSeccuesser {
	
    public static int getSum(int[] arr) {
    	int sum =0;
    	for(int i=0; i<arr.length; i++) {
    		sum+= arr[i]*(arr[i]+1);
    	}
    	return sum;
    }
	public static void main(String[] args) {
		 Scanner sc = new Scanner(System.in);
		 int n = sc.nextInt();
		 int[] arr = new int[n];
		 for(int i=0; i<n; i++) arr[i] = sc.nextInt();
		 System.out.println(getSum(arr));
	}
}

If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.

MindTree Question 12 : Number of elements in array between upper-bound and lower-bound

import java.util.Scanner;
public class NumberOfElementsInBetweenArray {

	public static int getCount(int[] arr, int l, int u) {
	   int c = 0;
	   for(int x : arr) {
		   if((x >= l) && (x <= u)) {
			   c++;
		   }
	   }
	   return c;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int low = sc.nextInt();
		int  up = sc.nextInt();
		int size = sc.nextInt();
		int[] arr = new int[size];
		for(int i=0; i<size; i++) arr[i] = sc.nextInt();
		System.out.println(getCount(arr, low, up));
	}
}
If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.

Mindtree Question 13: Palindromes in given String

import java.util.Arrays;
import java.util.Scanner;
public class PalindromString {
	static int dp[][] = new int[1001][1001];
	public static int isPal(String s, int i, int j) {
		if (i > j)
			return 1;
		if (dp[i][j] != -1)
			return dp[i][j];
		if (s.charAt(i) != s.charAt(j))
			return dp[i][j] = 0;
		return dp[i][j] = isPal(s, i + 1, j - 1);
	}
	public static int countSubstrings(String s) {
		for (int[] row : dp) {
			Arrays.fill(row, -1);
		}
		int n = s.length();
		int count = 0;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				if (isPal(s, i, j) != 0) {
					if (s.substring(i,j+1).length() == 4)
						count += 5;
					if (s.substring(i,j+1).length() == 5)
						count += 10;
				}
			}
		}
		return count;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		System.out.println(countSubstrings(s));
	}
}
If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.

Mindtree Question 14: LCM (Lowest Common Multiple

You are given an array of positive integers, arr of size of array_length. Your are asked to build set $ which consist of the LCM pair of every pair of adjacent elements in arr. Your task is to find the largest elements in set S.
For example for the array[1,,3,4] set S = {lcm(1,2), lcm(2,3), lcm(3,4)} = {2,6,12}. The largest is 12
Notes:
The array contains only positive integer.
Adjacent elements may NOT be circular, i.e they may not wrap around the end of the array.
Sample Cases:
Input:
4
1 3 2 4
Output:
6
Explanation:
set S = {lcm(1,3), lcm(3,2), lcm(2,4)}={3,6,4} Largest elements =6
Input:
4
1 2 3 4
Output:
12
Input:
5
7 3 2 9 12
Output:
12

Solution

import java.util.Scanner;
public class Lcm {
	 private static int computeGCD(int num1, int num2) {
	        while (num1 != num2) {
	            if (num1 > num2)
	                num1 -= num2;
	            else
	                num2 -= num1;
	        }   
	        return num2;
	    }
	    private static int computeLCM(int num1, int num2, int gcd) {
	        return (num1*num2)/gcd;
	    }
	public static void main(String[] args) {
		 Scanner sc = new Scanner(System.in);
		 int n = sc.nextInt();
		 int[] number = new int[n];
		 for(int i=0; i<n; i++) number[i] = sc.nextInt();
		 int max = Integer.MIN_VALUE;
		 int temp = 0;
		 for(int i=0; i<n-1; i++) {
		  	 temp = computeLCM(number[i], number[i+1],computeGCD(number[i], number[i+1]));
		  	 if(temp > max) max = temp;
		 }
		 System.out.println(max);
	}
}
If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.

Question 15 : Coming Soon

Some Frequently Asked Questions

For such types of questions highlight the core principles of the company and the work culture which motivates you to join the company. Talk about your desire to grow and learn while working in this company as your prime reason. Also, state the reviews of the company which you have heard from your seniors currently working for this company.

The Mindtree is a programming test which is conducted to evaluate the candidates which are good in programming skills.

Mainly two questions are asked in the exam in which the first question is based on patterns and the second is based on strings or matrices which is hard..

The Automata pro is an exam similar to MindTree which evaluates the candidates with good programming skills.

MindTree presently pays trainees an average salary of Rs. 3.2 lakh per year (roughly Rs 26,700 per month).

There is no bond, however you are required to sign a service agreement on your first day. There is a service agreement in place for campus hires as well. The service agreement is usually for a period of 24 months and a sum of 2 lakh. You can leave the company without an experience certificate or proof, but you must pay the sum owed if you leave before the end of the service agreement period.

Comments

Post a Comment

If you any doubts, please let me know Telegram Id: @Coding_Helperr
Instagram Id : codingsolution75

More Related

For Any Help Related to coding exams follow me on Instagram : codingsolution75

Popular Posts

WIPRO Latest Coding Questions with Solutions : 2023

EPAM Latest Coding Questions with Solutions 2023

Fresco Play Hands-on Latest Solutions

TCS Digital Exam | DCA | Direct Capability Assessment

TCS Wings 1 All Prerequisite

Infosys | InfytTq | Infosys Certification Exam Latest Coding Questions with Solutions

RAKUTEN Latest Coding Questions with Solutions

Cognizant

TypeScript Complete Course With Completed Hands-on