Mindtree Final Material
Mindtree Final Material
PREPARATION
youtube.com/@teknouf
ubk anna
CODING
Here, you can practice mindtree miscellaneous coding questions
based on implementation, DS/Algo and Advanced Algo section that
comes in exam. These are some of the common ques asked in
mindtree coding test.
UF
You can find these questions screenshots at previous year paper
folder
Pattern based Programs.
Remove vowel from the given String.
Eliminate repeated array from the given string.
Counting the number of even and odd elements in an array.
Replace a sub-string in a string.
Loop Based Programs.
O
Find Prime Numbers up to n.
Reverse a String.
KN
TE
youtube.com/@teknouf
ubk anna
CODING
Dani has N cups that needs to be filed with soda and each cup
has a different capacity of soda that it can hold.
Dani has a particular method of filing the cups. He chooses a
certain amount, say M, and fills all the cups with M litters of
soda. if the cup's capacity is less than M, the extra soda
overflows and splatters the ground.
It is given that Dani wants the sum of the soda that is held in the
UF
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 allows him
to meet the conditions given above,,if no value of M that allows
him to meet the condition, cutput -1.
Function Description
Complete the cups function in the editor below.
O
The function must return an INTEGER denoting the The smallest
value of M that Dani should choose such that amount of soda in
KN
the
cups is at least L. and - 1 il he can't choose such M.,
5
2
3
TE
4
5
6
15
OP:
4
youtube.com/@teknouf
ubk anna
def cups(N, capacities, L):
max_capacity = max(capacities)
UF
total_soda = sum(min(mid, capacity) for capacity in
capacities)
if total_soda >= L:
result = mid
right = mid - 1
else:
left = mid + 1
O
return result
N = int(input())
KN
youtube.com/@teknouf
ubk anna
import java.util.Scanner;
UF
int left = 0, right = maxCapacity;
int result = -1;
}
}
return result;
}
int N = sc.nextInt();
int[] capacities = new int[N];
int L = sc.nextInt();
youtube.com/@teknouf
ubk anna
CODING
There are N cloud servers, each having & value indicating their
usage. You are asked to perform the operation described below
on these server
In a single operation, you can start more tasks in the lost busy
server (any of them in case of to). This will increase the chosen
server's usage value by 1.
UF
You know your manager is coming over soon to review the cloud
server usage. it is also guaranteed that he will only be
concerned with the K-th smallest usage value among the
cloud servers. You only have the time for M operations before
your manager arrives.
Your task is to find the largest possible value for the K-th
smallest usage in the given scenario.
O
N=5
usages = [1, 2, 3, 4, 5]
K=3
KN
M=3
O/P:
3
TE
youtube.com/@teknouf
ubk anna
CODING
def max_kth_smallest_usage(N, usages, K, M):
usages.sort()
for _ in range(M):
usages[0] += 1
UF
i=0
while i < N - 1 and usages[i] > usages[i + 1]:
usages[i], usages[i + 1] = usages[i + 1], usages[i]
i += 1
return usages[K - 1]
N=5
O
usages = [1, 2, 3, 4, 5]
K=3
M=3
KN
youtube.com/@teknouf
ubk anna
CODING
import java.util.Arrays;
UF
K, int M) {
Arrays.sort(usages);
System.out.println(maxKthSmallestUsage(N, usages, K,
M));
}
}
youtube.com/@teknouf
ubk anna
CODING
Abhijeet is one of those students who tries to get his own money
by part time jobs in various places to fill up the expenses for
buying books. He is not placed in one place, so what he does, he
tries to allocate how much the book he needs will cost, and then
work to earn that much money only. He works and then buys the
UF
book respectively. Sometimes he gets more money than he needs
so the money is saved for the next book. Sometimes he doesn’t. In
that time, if he has stored money from previous books, he can
afford it, otherwise he needs money from his parents.
Now His parents go to work and he can’t contact them amid a day.
You are his friend, and you have to find how much money minimum
he can borrow from his parents so that he can buy all the books.
O
He can Buy the book in any order.
Function Description:
KN
youtube.com/@teknouf
ubk anna
CODING
Constraints:
UF
First line contains N.
Second N lines contain The ith earning for the ith book.
After that N lines contain The cost of the ith book.
Output Format: The minimum money he needs to cover the total
expense.
Sample Input 1:
O
3
[3 4 2]
KN
[5 3 4]
Sample Output 1:
3
TE
Explanation:
youtube.com/@teknouf
ubk anna
CODING
n=int(input())
L1=[0] *n
L2=[0]*n
for i in range(n):
L2[i]=int(input())
for i in range(n):
UF
L1[i]=int(input())
for i in range(n):
L2[i]=L2[i]-L1[i];
L2.sort()
su=0
ans=0
for i in range(n):
su=su+L2[i]
O
if su<0:
ans = ans + abs(su)
su=0
print(ans)
KN
TE
youtube.com/@teknouf
ubk anna
CODING
import java.util.Scanner;
import java.util.Arrays;
UF
int n = sc.nextInt();
int[] L1 = new int[n];
int[] L2 = new int[n];
int su = 0;
int ans = 0;
su = 0;
}
}
System.out.println(ans);
sc.close();
}
}
youtube.com/@teknouf
ubk anna
CODING
Nobel Prize-winning Austrian-Irish physicist Erwin Schrödinger
developed a machine and brought as many Christopher Columbus
from as many parallel universes he could. Actually he was quite
amused by the fact that Columbus tried to find India and got
America. He planned to dig it further.
UF
Though totally for research purposes, he made a grid of size n X
m, and planted some people of America in a position (x,y) [in 1
based indexing of the grid], and then planted you with some of
your friends in the (n,m) position of the grid. Now he gathered all
the Columbus in 1,1 positions and started a race.
further.
Function Description:
youtube.com/@teknouf
ubk anna
CODING
Constraints:
UF
Input Format:
Sample Input 1
2
TE
Sample Output 1
Explanation
The only way possible is (1,1) ->(2,1) -> (2,2), so the answer is 1.
youtube.com/@teknouf
ubk anna
CODING
import math
n=int(input())-1
m=int(input())-1
x=int(input())-1
y=int(input())-1
UF
ans=math.factorial(n+m)
ans=ans//(math.factorial(n))
ans=ans//(math.factorial(m))
ans1=math.factorial(x+y)
ans1=ans1//(math.factorial(x))
ans1=ans1//(math.factorial(y))
x1=n-x
y1=m-y
O
ans2=math.factorial(x1+y1)
ans2=ans2//(math.factorial(x1))
ans2=ans2//(math.factorial(y1))
print(ans-(ans1*ans2))
KN
TE
youtube.com/@teknouf
ubk anna
CODING
import java.util.Scanner;
UF
int n = sc.nextInt() - 1;
int m = sc.nextInt() - 1;
int x = sc.nextInt() - 1;
int y = sc.nextInt() - 1;
sc.close();
}
youtube.com/@teknouf
ubk anna
CODING
Aashay loves to go to WONDERLA , an amusement park. They
are offering students who can code well with some discount. Our
task is to reduce the cost of the ticket as low as possible.
They will give some k turns to remove the cost of one ticket
UF
where the cost of tickets are combined and given as string.Help
Aashay in coding as he is not good in programming and get a
50% discount for your ticket.
Constraints:
Sample Input 1
203
TE
3
Sample Output 1
0
youtube.com/@teknouf
ubk anna
CODING
import sys
n = input()
k = int(input())
n1 = len(n)
UF
if len(n) <= k:
print(0)
sys.exit()
a = ''
i=0
else:
a += n[i]
i += 1
a += n[i]
i += 1
TE
if k > 0:
a = a[:-k]
youtube.com/@teknouf
ubk anna
CODING
import java.util.Scanner;
import java.util.Stack;
String n = sc.nextLine();
int k = Integer.parseInt(sc.nextLine());
UF
int n1 = n.length();
if (n1 <= k) {
System.out.println(0);
return;
}
stack.push(n.charAt(i));
i++;
}
while (k > 0) {
stack.pop();
k--;
}
TE
while (!stack.isEmpty()) {
a.insert(0, stack.pop());
}
if (a.length() == 0) {
System.out.println(0);
} else {
long result = Long.parseLong(a.toString()) % ((long)
Math.pow(10, 9) + 7);
System.out.println(result);
}
sc.close();
}
}
youtube.com/@teknouf
ubk anna
CODING
In an airport , the Airport authority decides to charge some
minimum amount to the passengers who are carrying luggage with
them. They set a threshold weight value, say T, if the luggage
exceeds the weight threshold you should pay double the base
amount. If it is less than or equal to threshold then you have to pay
$1.
UF
Function Description:
youtube.com/@teknouf
ubk anna
CODING
Returns: The function must return an INTEGER denoting the
required amount to be paid.
Constraints:
UF
1 <= weights[i] <= 10^5
1 <= T <= 10^5
Input Format for Custom Testing:
Sample Input 1
4
1
2
3
4
3
TE
Sample Output 1
5
Explanation:
Here all weights are less than threshold weight except the
luggage with weight 4 (at index 3) so all pays base fare and it
pays double fare.
youtube.com/@teknouf
ubk anna
CODING
def weightMachine(N,weights,T):
amount=0
for i in weights:
amount+=1
if(i>T):
amount+=1
UF
return amount
N=int(input())
weights=[]
for i in range(N):
weights.append(int(input()))
T=int(input())
print(weightMachine(N,weights,T))
O
KN
TE
youtube.com/@teknouf
ubk anna
CODING
import java.util.Scanner;
UF
for (int i = 0; i < N; i++) {
amount += 1;
if (weights[i] > T) {
amount += 1;
}
}
return amount;
}
O
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
KN
int N = sc.nextInt();
int[] weights = new int[N];
int T = sc.nextInt();
sc.close();
}
}
youtube.com/@teknouf
ubk anna
CODING
Write a program to find the average of the first P multiples of an
integer N.
UF
Function Description
Constraints
1 < N < 30
TE
1 < P < 10
youtube.com/@teknouf
ubk anna
CODING
UF
O
KN
TE
youtube.com/@teknouf
ubk anna
CODING
def average():
sum=0
n=int(input())
p=int(input())
UF
for i in range(n,(n*p+1),n):
sum=sum+i
return int(sum/p)
print(average())
O
KN
TE
youtube.com/@teknouf
ubk anna
CODING
import java.util.Scanner;
UF
Scanner sc = new Scanner(System.in);
int sum = 0;
int n = sc.nextInt();
int p = sc.nextInt();
return sum / p;
}
youtube.com/@teknouf
ubk anna
CODING
Write a program to reverse the characters in the individual strings
Function Description
UF
Complete the reverseString function. It has the following
parameter(s):
O
Constraints
KN
youtube.com/@teknouf
ubk anna
CODING
UF
O
KN
TE
youtube.com/@teknouf
ubk anna
CODING
def reverseWord():
List = list(input().split(" "))
updatedList= [x[::-1] for x in List]
return str(' '.join(updatedList))
UF
print(reverseWord())
O
KN
TE
youtube.com/@teknouf
ubk anna
CODING
import java.util.Scanner;
UF
String input = sc.nextLine();
String[] words = input.split(" ");
StringBuilder result = new StringBuilder();
youtube.com/@teknouf
ubk anna
CODING
You are given a function that takes an integer N. Write a
program that returns the sum of all the even numbers which are
less than or equal to N.
UF
For examples, refer to the sample cases given below.
O
KN
Function Description
youtube.com/@teknouf
ubk anna
CODING
def sumEven():
num=int(input())
sum=0
for i in range(0,num+1,2):
sum+=i
UF
return sum
print(sumEven())
O
KN
TE
youtube.com/@teknouf
ubk anna
CODING
import java.util.Scanner;
UF
Scanner sc = new Scanner(System.in);
int num = sc.nextInt();
int sum = 0;
System.out.println(sumEven());
}
}
TE
youtube.com/@teknouf
ubk anna
CODING
You are given an integer array containing the IDs of a product.
Write a program to calculate the number of repetitions of the given
ID in the array and return the count.
UF
Sample Cases:
O
KN
TE
Function Description
youtube.com/@teknouf
ubk anna
CODING
Constraints
youtube.com/@teknouf
ubk anna
CODING
def getCount():
l=[]
size=int(input())
for i in range(size):
UF
c=int(input())
l.append(c)
ID=int(input())
return l.count(ID)
print(getCount())
O
KN
TE
youtube.com/@teknouf
ubk anna
CODING
import java.util.ArrayList;
import java.util.Scanner;
UF
Scanner sc = new Scanner(System.in);
ArrayList<Integer> list = new ArrayList<>();
int size = sc.nextInt();
return count;
TE
youtube.com/@teknouf
ubk anna
CODING
Write a program to calculate the number of vowels present in the
string
UF
Function Description
Constraints
youtube.com/@teknouf
ubk anna
CODING
UF
O
KN
TE
youtube.com/@teknouf
ubk anna
CODING
def vowels():
count=0
s=input()
for i in s:
UF
if i in 'aeiou':
count+=1
return count
print(vowels())
O
KN
TE
youtube.com/@teknouf
ubk anna
CODING
import java.util.Scanner;
UF
String s = sc.nextLine();
int count = 0;
youtube.com/@teknouf
ubk anna
Practice
UF
O
KN
Coding Questions
TE
Technical Questions
youtube.com/@teknouf
ubk anna
INTERVIEW
EXPERIENCE
UF
O
KN
TE
youtube.com/@teknouf
ubk anna
MOCK TESTS
UF
O
KN
TE
youtube.com/@teknouf
ubk anna
AFFORDABLE PLACEMENT MATERIALS
UF
O
69 X 6 = 414/- PAY ONLY
KN
249/-
TO GET 👆🏽
DM - 👇🏽
TE
INSTAGRAM.COM/TEKNO.UF
2025
youtube.com/@teknouf
ubk anna