## Tuesday, September 6, 2016

### MindTree Coding questions-2

Hello Everyone,

Practice the following programs and most likely you can clear mind tree coding exam conducted by amcat. Any queries related to mindtree drive, contact me @ reachmeatbhanu@gmail.com

1.    Removal of vowel from string
2.    GCD of two numbers.
3.    Eliminate repeated letters in Array.
4.    Various patterns of triangle etc.
5.    Star pattern programs
6.    string reversal
7.    GCD of array of numbers
8.    Arrays and strings.
9.    Print and count all the numbers which are less than a given key element from our array.
10.  Sorting programs
11.  Find whether array is a palindrome or not
12.  Input 5 numbers in an array and find the Pythagorean triplets in them and print it.

13.  Write a function that accepts a sentence as a parameter, and returns the same with each of its words reversed. The returned sentence should have 1 blank space between each pair of words. Example:
Parameter: “jack and jill went up a hill”
Return Value: “kcaj dna llij tnew pu a llih”
14.  Pascal triangle program
15.  Print following pattern
Input:4
1222
2333
3444
4555
Input:5
12222
23333
34444
45555
56666

16.  Display array dissimilar numbers
Given two arrays and need print (A-B)U(B-A)

17.  Mirror image of a matrix.
18.  To delete a specified a letter from a given word
19.  Input is any odd number
a.       If n=3
1 2 3 10 11 12
4 5 8    9
6 7
If n=5
1 2 3 4 5 26 27 28 29 30
6 7 8 9 22 23 24 25
10 11 12 19 20 21
13 14 17 18
15 16

20.  Input string : bhanu
Output: bhanu, hanub, anubh, nubha, ubhan

21.  Prime numbers upto n numbers

22.  ((()) If the no of open and closing braces match ok else print -1 ( matching Parenthesis )

23.
1
2  2
3 3 3
4 4 4 4
4 4 4 4
3 3 3
2 2
1

24.  Two arrays given and combine them and sorting order.
25.  Frequency sorting algorithm
26.  Input is- series of numbers( take an array to store)
Ex: test case1:- 16734515888801
Output should be the:-
number which had appeared highest no.of times- how many times it occurred in sequence.
8-4
1-3
5-2
27.  tring reversal with out using temporary array
28.  Removal of vowels from string with out temporary array
29.  String palindrome or not
30.  Alternate sorted array
31.  merge sort using dynamic memory allocation.
32.  multiplication of two matrices and print the result in transverse order
33.  Given an array of n elements and we need to find the least number repetition count
a.       Example 3 4 4 5 3
i.      Least number is 3 and repeated two times so output: 2

34.  Pattern
1
2 3
6 5 4
7 8 9 10

35.  factorial and hcf programs

36.  Swapping the array index and array values
37.  Input a number let’s say 3 ,.. we need to make a matrix
1 2 3
4 5 6
7 8 9
And its transpose. multiply the matrix with it’s transpose and return it
38.  Given a number and a digit. We need to find out how many times  digit occurred in the number
Example: 12134  and digit is 1
As 1 present 2 times so we need to print 2
39.   Pattern program
1 2 3 4
9 10 11 12
13 14 15 16
5 6 7 8
40.  Balanced parenthesis. If string is balanced then print number of balanced parenthesis otherwise -1
41.  Pattern program
1
2*2
3*3*3
4*4*4*4
4*4*4*4
3*3*3
2*2

42.  Pattern program
1*2*3*4
9*10*11*12
13*14*15*16
5*6*7*8

43.  Cell compete

There is a  colony of 8 cells arranged in a straight line where each day every cell competes with its adjacent cells(neighbour).
Each day, for each cell, if its neighbours are both active or both inactive, the cell becomes inactive the next day,. otherwise itbecomes active the next day.
Assumptions:
The two cells on the ends have single adjacent cell, so the other adjacent cell can be assumsed to be always inactive.
Even after updating the cell state. consider its pervious state for updating the state of other cells. Update the cell informationof allcells simultaneously.
Write a fuction cellCompete which takes takes one 8 element array of integers cells representing the current state of 8 cells and one integer days representing te number of days to simulate.
An integer value of 1 represents an active cell and value of 0 represents an inactive cell.
program:
int* cellCompete(int* cells,int days)
{
//function signature ends
TESTCASES 1:
INPUT:
[1,0,0,0,0,1,0,0],1
EXPECTED RETURN VALUE:
[0,1,0,0,1,0,1,0]
TESTCASE 2:
INPUT:
[1,1,1,0,1,1,1,1,],2
EXPECTED RETURN VALUE:

[0,0,0,0,0,1,1,0]

44.  Pattern n=4 and s=3
3
4 4
5 5 5
6 6 6 6
6 6 6 6
5 5 5
4 4
45.  Pattern
1111112
3222222
3333334
5444444
5555556

46.  Combine two arrays then sort
47.  Pattern
1
3*2
4*5*6

48.  Grey character program

Name

Email *

Message *