TCS CodeVita Cheat Sheet
TCS CodeVita Cheat Sheet
Resources:
https://prepinsta.com/tcs-codevita/practice-questions-with-answers/
https://www.faceprep.in/tcs/tcs-codevita-questions/
https://www.geeksforgeeks.org/tcs-codevita-9-pre-qualifier-round-questions/
Some Important Problems :
Question -:You are given a binary string B of length L which contains K ones and
remaining zeros. You are required to place the K ones in the binary string in such a
way that the longest consecutive zeros have the least length possible. Once such a
binary string is constructed, you are required to print the length of the contiguous
block of zeros, which has the largest length.
Constraints
0 <= K <= L
Input
Output
Print a single integer denoting the length of the longest consecutive zeros as per the
problem.
Examples
Example 1
Input
31
Output
1
Explanation
So the possible strings as per the problem are 010, 001, 100.
In the first case, the maximum length of consecutive zeros is 1 whereas in the other
two cases it is 2. Hence the constructed binary string is 010 and the output is 1.
Example 2
Input
33
Output
Explanation
B is of length 3 and it has all three one’s. There is no block of zeros, hence the
output is 0.
Question -: Consider a set of web pages, numbered from 1 to N. Each web page
has links to one or more web pages. Clicking on a link in a page, takes one to the
other web page. You are provided numbers of two web pages viz, starting web page
and end web page. Your task is to find the minimum number of clicks required to
reach the end page from the start page. If end page cannot be reached from start
page, print -1 as the output. For better understanding refer Examples section.
Constraints
0 < L < 10
Input
First line contains an integer N denoting number of web pages.
Next N lines contain L space separated integers depicting linked webpage number(s)
from that webpage
Output
Print the minimum number of clicks required to open the end page from start page. If
not possible, print -1 as output.
Example 1
Input
24
15
23
23
Output
Explanation:
Fourth line conveys that there are links from page 3 to pages 1 and 5.
Fifth line conveys that there are links from page 4 to pages 2 and 3.
Sixth line conveys that there is a links from page 5 to page 5 itself.
From page 2, we can open only page 1. From page 1, we can open page 4. From
page 4, we can open page 3. So, minimum 3 clicks are required, and this is the
output.
Example 2
Input
23
Output
-1
Explanation:
Second line conveys that there are links from page 1 to page 2.
Third line conveys that there is a link from page 2 to page 1.
Fourth line conveys that there are links from page 3 to page 1.
Question -: A picnic to a famous museum is being planned in a school for class VI.
When they reached the spot, the students started quarreling among themselves in
the queue. So the teacher came up with an idea of “good string” which is explained
below.
Good String is provided as input. All letters in this string are good letters. Good
letters need to be used in further computations as explained below.
The teacher asked all the students to convert their names into good names with the
help of good string. While converting, they have to calculate the distance. Based on
that, she will arrange the students in a queue.
For converting a name into good name, for each letter i in the name, select the
nearest letter from the good name. Distance is calculated as the differences between
the ASCII values of i and selected good letter. If there are two letters which are
equidistant from i, select the letter which is nearest to the previously used good
letter. In that case, distance will be the difference of ASCII value of previously used
good letter and selected letter. If i is already present in the good string then no need
to change it. Initially, previous good letter will be the first letter of good string.
Calculate the total distance of the given name.
Given the name of the student who is confused of implementing this task. Help him
to calculate the total distance for his name.
Note: Letters from good string can be reused any number of times.
Constraints
1 <= len(good string) <= 100
1 <= len(name) <= 10^4
Good string will consist of lower, upper case alphabets, digits and symbols.
Name will consist of only space, lower and upper case alphabets.
Characters are case sensitive.
The ASCII values for all the characters in the good string and name will be between
32 to 126 (both inclusive).
Input
First line consists of good string.
Second line consists of the name of the student who is confused to implement the
task.
Output
Print the total distance for that name.
Examples
Example 1
Input
(@HR*i{kcQl
Vyom
Output
10
Explanation
i
Previous good letter
Current good letter for i
V
(
R
y
R
{
o
{
l
m
l
l
The total distance will be |ASCII(V)-ASCII(R)| + |ASCII(y)-ASCII({)| +
|ASCII(o)-ASCII(l)| + |ASCII(m)-ASCII(l)| = 4+2+3+1 = 10.
Example 2
Input
6*K4AQf]gpi
Nainika
Output
33
Explanation
i
Previous good letter
Current good letter for i
N
6
K
a
K
]
i
–
–
n
]
p
i
–
–
k
p
i
a
i
]
Initially, Previous good letter=6. Since K and Q are at the same distance from N, so
we select the character which is nearest to previous letter(6) which is K.
i is already present in the good string. So no need to change anything.
Therefore, total distance will be |ASCII(6)-ASCII(K)| + |ASCII(a)-ASCII(])| +
|ASCII(n)-ASCII(p)| + |ASCII(k)-ASCII(i)| + |ASCII(a)-ASCII(])| = 21+4+2+2+4 = 33.
● From the given set of distinct natural numbers as input, consider the smallest
natural number as q.
● Your task is to compute the smallest prime number (p) such that when p is
divided by all the distinct numbers in the input, except q, should result q as the
remainder.
Constraints :
● 1 < n < 11
● p < 10 ^ 10
Input :
Output :
Print single integer p if such a p exists, else print “None”.
Example 1 :
Input :
3451
Output : 61
Explanation : Here the n+1 numbers are 3, 4, 5 and 1 where q=1 (the least of the
numbers)
The smallest number that leaves remainder 1 when divided by 3, 4 and 5 is 61 and is
prime. Hence, output is 61.
Example 2 :
Input :
3452
Output : None
Explanation : Here q=2. Any number that when divided by 4 leaving remainder 2
must be an even number e.g., 6, 10, 14 etc. Hence it can’t be prime. Hence, output
is “None”.
Question -: Consider a Jug of capacity L liters. Given N cups of different capacities
Ci (in liters), fill the Jug with the help of cups, according the specification.
The specification according to which the cups may be used to fill the Jug is as below
1. Cups can be used integral number of times i.e., zero or more times, but never
partially i.e., a cup of 1L can be used 0, 1, 2 etc. times, but never 0.5, 1.5, 2.5
.. times
2. The Jug must not overflow because of cup filling the Jug
3. The number of distinct cups (i.e., different cup sizes) used to fill the Jug must
be maximized
4. The summation of number of times all cups are used must be minimized.
optimisation goals.
For better understanding of how cups can be used to fill the Jug, go through the
Examples section. Both examples clearly explain, when there are multiple ways to
achieve the objective, what is the correct answer and why.
Constraints :
0 < N < 10
0 < Ci < L
Input :
First line contains an integer N denoting the number of cups available.
Second line contains N space separated integers denoting the capacity of the cups.
Third line contains an integer L which denotes the capacity of Jug in liters.
Output :
First line must comprise of N or less space delimited integers, in ascending order of
cup size, for the cups used to fill the Jug
Second line must comprise of equal number of space delimited integers which
denote the frequency i.e. the number of times the corresponding cup in first line is
used to fill the Jug.
Example 1 :
Input :
3 7 10 11
88
Output :
3 7 10 11
1261
Explanation :
The first and second lines indicate that you are provided with 4 cups of capacities – 3
liters, 7 liters, 10 liters and 11 liters. The third line indicates that the capacity of the
Jug is 88 liters.
7 10 11
523
i.e., one can use 7L cup for 5 times to get 35L. Next one can use the 10L cup twice.
After that the Jug will contain 55L. Finally, one can use 11L cup thrice. Thus, the Jug
will be filled. However, this solution uses cups of only 3 different capacities when 4
different capacities are available. Hence the Jug is perhaps not filled according to the
specification. Let’s see if we can achieve our objective by using all 4 cup sizes.
3 7 10 11
1261
Example 2 :
Input :
2 5 10
50
Output :
2 5 10
523
Explanation :
The first and second lines indicate that you are provided with 3 cups of capacities – 2
liters, 5 liters, 10 liters. The third line indicates that the capacity of the Jug is 50 liters.
Here one can easily fill the Jug by using the 10L cup 5 times. However, this does not
obey the specifications. According to the specifications, one must use all available
cups of capacity 2L, 5L and 10L. If there are multiple ways in which the Jug can be
filled by using maximum number of distinct sized cups, then as per specifications
one needs to minimize the summation of number of times cups are used.
Solution 1
2 5 10
15 2 1
Solution 2
2 5 10
523
Both solutions use all available cups. However, sum of frequencies in Solution 1 is
18 (15 + 2 + 1), whereas sum of frequencies in Solution 2 is 10 (5 + 2 + 3). Solution
2 minimizes the summation of number of times any cup in used. This is also a
requirement as per the specification. Hence Solution 2 is the correct answer.
Question . Sam is an eligible bachelor. He decides to settle down in life and start a family. He
goes bride hunting.
He wants to marry a girl who has at least one of the 8 qualities mentioned below:-
He is in search of a bride who has some or all of the 8 qualities mentioned above. On bride
hunting, he may find more than one contenders to be his wife.
In that case, he wants to choose a girl whose house is closest to his house. Find a bride for
Sam who has maximum qualities. If in case, there are more than one contenders who are at
equal distance from Sam’'s house; then
In case there is no suitable girl who fits the criteria then print “"No suitable girl found"”
Given a Matrix N*M, Sam's house is at (1, 1). It is denoted by 1. In the same matrix, the
location of a marriageable Girl is also denoted by 1. Hence 1 at location (1, 1) should not be
considered as the location of a marriageable Girl’s location.
The qualities of that girl, as per Sam’'s criteria, have to be decoded from the number of
non-zero neighbors (max 8-way) she has. Similar to the condition above, 1 at location (1, 1)
should not be considered as the quality of a Girl. See Example section to get a better
understanding.
Find Sam, a suitable Bride and print the row and column of the bride, and find out the
number of qualities that the Bride possesses.
NOTE: - Distance is calculated in number of hops in any direction i.e. (Left, Right, Up, Down
and Diagonal)
Constraints
2 <= N,M <= 10^2
Input Format
First Line contains the row (N) and column (M) of the houses.
Next N lines contain the data about girls and their qualities.
Output
It will contain the row and column of the bride, and the number of qualities that Bride
possess separated by a colon (i.e. :).
Explanation
Example 1
Input:
29
101101111
000101001
Output:
1:7:3
Explanation:
As we see, there are two contenders who have maximum qualities, one is at (1,7) and
another at (1,8).
The girl who is closest to Sam's house is at (1,7). Hence, she is the bride.
Hence, the output will be 1:7:3.
Example 2
Input:
66
100000
000000
001110
001110
001110
000000
Output:
4:4:8
Explanation:
The Bride present at (3,3) has 3 qualities (i.e. (3,4),(4,3) and (4,4)).
As we see, the girl present in (4,4) has maximum number of Qualities. Hence, she is the
bride.
The first line contains the original string s. The second line contains a single integer q. The
ith of the next q lines contains character d[i] denoting direction and integer r[i] denoting the
magnitude.
Constraints
1 <= Length of original string <= 30
1<= q <= 10
Output
YES or NO
Question
During the battle of Mahabharat, when Arjuna was far away in the battlefield, Guru Drona made a
Chakravyuha formation of the Kaurava army to capture Yudhisthir Maharaj. Abhimanyu, young
son of Arjuna was the only one amongst the remaining Pandava army who knew how to crack
the Chakravyuha. He took it upon himself to take the battle to the enemies.
Abhimanyu knew how to get power points when cracking the Chakravyuha. So great was his
prowess that rest of the Pandava army could not keep pace with his advances. Worried at the
rest of the army falling behind, Yudhisthir Maharaj needs your help to track of Abhimanyu's
advances. Write a program that tracks how many power points Abhimanyu has collected and
also uncover his trail
A Sequential order of units differs structurally based on the radius of the Chakra. The radius can
be thought of as length or breadth of the matrix depicted above. The structure i.e. placement of
units in sequential order is as shown below
The entry point of the Chakravyuha is always at the (0,0) co-ordinate of the matrix above. This is
where the 1st army unit guards. From (0,0) i.e. 1st unit Abhimanyu has to march towards the
center at (2,2) where the 25th i.e. the last of the enemy army unit guards. Remember that he has
to proceed by destroying the units in sequential fashion. After destroying the first unit, Abhimanyu
gets a power point. Thereafter, he gets one after destroying army units which are multiples of 11.
You should also be a in a position to tell Yudhisthir Maharaj the location at which Abhimanyu
collected his power points.
Input Format: First line of input will be length as well as breadth of the army units, say N
Output Format:
● Print NxN matrix depicting the placement of army units, with unit numbers delimited by
(\t) Tab character
● Print Total power points collected
● Print coordinates of power points collected in sequential fashion (one per line)
Question 5.
There are two banks; Bank A and Bank B. Their interest rates vary. You have received
offers from both bank in terms of annual rate of interest, tenure and variations of rate of
interest over the entire tenure.
You have to choose the offer which costs you least interest and reject the other.
The loan repayment happens at a monthly frequency and Equated Monthly Installment
(EMI) is calculated using the formula given below :
( 1 - 1 / (1 + monthlyInterestRate)^(numberOfYears * 12))
Constraints
1 <= P <= 1000000
1 <=T <= 50
1<= N1 <= 30
1<= N2 <= 30
Input Format
First line : P – principal (Loan Amount)
Third Line : N1 is number of slabs of interest rates for a given period by Bank A. First slab
starts from first year and second slab starts from end of first slab and so on.
Next N1 line will contain the interest rate and their period.
After N1 lines we will receive N2 viz. the number of slabs offered by second bank.
Next N2 lines are number of slabs of interest rates for a given period by Bank B. First slab
starts from first year and second slab starts from end of first slab and so on.
Output
Your decision – either Bank A or Bank B.
Explanation
Example 1
Input
10000
20
5 9.5
10 9.6
5 8.5
10 6.9
5 8.5
5 7.9
Output
Bank B
Example 2
Input
500000
26
13 9.5
3 6.9
10 5.6
14 8.5
6 7.4
6 9.6
Output
Bank B
Question .
Given an MxN matrix, with a few hurdles arbitrarily placed, calculate the cost of longest possible
route from point A to point B within the matrix.
Input Format:
1. First line contains 2 numbers delimited by whitespace where, first number M is number
of rows and second number N is number of columns
2. Second line contains number of hurdles H followed by H lines, each line will contain one
hurdle point in the matrix.
3. Next line will contain point A, starting point in the matrix.
4. Next line will contain point B, stop point in the matrix.
Output Format:
Output should display the length of the longest route from point A to point B in the matrix.
Constraints:
1. The cost from one position to another will be 1 unit.
2. A location once visited in a particular path cannot be visited again.
3. A route will only consider adjacent hops. The route cannot consist of
diagonal hops.
4. The position with a hurdle cannot be visited.
5. The values MxN signifies that the matrix consists of rows ranging from 0 to
M-1 and columns ranging from 0 to N-1.
6. If the destination is not reachable or source/ destination overlap with
hurdles, print cost as -1.
2
22 -1 No path is possible in this 2*2 matrix so answer is -1
1
00
11
00
Question .
Stark is a 10 year old kid and he loves stars. So, he decided every day he will capture a picture
of a sky. After doing this for many days he found very interesting observations.
Every day the total number of stars in the sky is same as days completed for a calendar year. He
noticed, on Saturday's and Sunday's that there are no stars in the sky. Stark's camera does not
have wide angle capture feature so he could only capture maximum of 50 stars at a time. So, he
assumed that there are only 50 stars in the sky that day. Also, the camera discharges every 4th
day and he is not be able to click any picture that day. So let's say, if the first day of calendar
(01/01/0001) starts on a Monday then on Thursday he can't click any pictures. Then resuming on
Friday he can take pictures until Sunday, but can't take picture on Monday, followed by downtime
on Friday, then Tuesday, then Saturday etc. When the camera discharges he considers 0 stars
that day.
You are his programmer friend and want to help him. You need to write a code which will tell him
on a particular date how many stars Stark's camera was able to click.
You can assume Stark has an ancient camera and your first input will be the day for date
(01/01/0001) and then followed by any date on which Stark wants to find out the number of stars
in the sky.
Input Format:
Every line of input will contain a Day at date 01/01/0001 in dd/mm/yyyy format followed by a Date
in the same format (on which we have to count the stars)
Output Format:
For valid Input
Count of the number of stars in the sky on the given date
1
Monday Invalid Date
30/02/1990
2
Thursday Invalid Day
3
Wednesday 24 Its 24th day of the year and neither is
24/01/2056 Saturday/Sunday nor has the camera discharged
on this day.
Question
Darrell and Sally are two best friends. They had a large collection of marbles. They devised a
game with it to play in their free time which will also help them to improve their math. One of
them will have to select a certain number of marbles and give a hint to find the number. The other
will have to guess the first number that matches the given criteria and vice versa.
Your task is to act as a judge for this game. When the player finds the answer, you will have to
verify the answer. If answer is right, add 10 points to that player. If the player passes the
question, you will have to give the right answer (no change in points in this case). You should
also announce the winner at the end of the game.
When the marbles are put into a group of x1, x2, x3,...(where x1, x2, x3 can be any number from
1 to 100), it falls into a perfect group.(No marble is left without a group).
Example: - When Darrell says the number falls into a perfect set when she groups them into sets
of 3 and 5, the answer could be 15 or 30 and so on. Since the first number that matches the
criteria is 15, 15 will be the answer.(Explanation: when 15 marbles is put into groups of 3, We will
get 5 sets of 3 marbles each and when it is put into groups of 5, we will get 3 sets of 5 marbles
each. For 16 marbles, we will get 5 sets of 3 marbles each and one marble will be left without a
proper group. So 16 cannot be the answer)
NOTE: - Please have a look at Sample Input and Output before you read the Input and Output
specification
Input Format:
Output Format:
1. First line of output must reiterate the question in the following format < Player
Name >'s question is : X1,X2,X3...,Xn>
9.
Second line should be an evaluation of the first Answer Giving line of the input. The
evaluation message will either be { Correct Answer or Wrong Answer}
10. If the answer
1. is correct, output, : 10points
2. is wrong, output, : 0points
3. is "PASS"-ed by the player,
1. output "Question is PASSed"
2. output "Answer is: " where correct_answer_value is the correct answer for
the question passed by the player.
3. output ": 0points"
4. Overall points collected by players have to be tracked and output when all valid
inputs are processed
11. If all inputs are valid, after processing all the inputs, the final output should be comprised
of the following 4 lines
1. Output "Total Points:" on fourth last line
2. Output ": points" on 3rd last line, where Player1 is the one who first posed the
question
3. Output ": points" on 2nd last line, where Player2 is the one who first answered the
question
4. If there is a winner Output "Game Result: is winner" or "Game Result: Draw"
12. Print "Invalid Input" in case of invalid input or failing constraint
13.
Constraints:
1. 0 < N <= 10
2. Player Names are Case-sensitive
3. Number of inputs in a Question posing line will be 2<=n<=7 and 1<=Xn<=100
4. <X1 ,X2,X3...,Xn> can only be integers
14.
3 2 Invalid Input
Darrell
A Sally 15
4 4 Sally's question is: 3,5
Sally 3,5 Correct Answer
A Darrell 15 Darrell: 10points
Darrell Invalid Input
A Sally 15
Question :
Elections are going on, and there are two candidates A and B, contesting with each other. There
is a queue of voters and in this queue some of them are supporters of A and some of them are
supporters of B. Many of them are neutral. The fate of the election will be decided on which side
the neutral voters vote. Supporters of A and supporters of B make attempt to win the votes of
neutral voters.
1. The voter queue is denoted by three characters, viz {-, A, B}. The – denotes neutral candidate,
A denotes supporter of candidate A and B denotes supporter of candidate B.
2. Supporters of A can only move towards the left side of the queue.
3. Supporters of B can only move towards the right side of the queue.
5. They both will try and influence the neutral voters by moving in their direction in the queue. If
supporter of A reaches the neutral voter before supporter of B reaches him, then that neutral
voter will become a supporter of candidate A.
6. Similarly, if supporter of B reaches the neutral voter before supporter of A reaches him, then
that neutral voter will become a supporter of candidate B.
7. Finally, if both reach at the same time, the voter will remain neutral. A neutral vote cannot
decide the outcome of the election.
8. If finally, the queue has more votes for candidate A, then A wins the election. If B has more
votes, then B wins that election. If both have equal votes, then it will be a coalition government.
Refer Examples section for understanding the dynamics of how the supporters influence the
neutral voters.
Note: There are no test cases where all votes are neutral.
Input
· – = neutral voter
Output
Print candidate with maximum number of votes. If they have equal number of votes, print
“Coalition government“.
Examples
Input :14
–AB–AB—A–
Output : A
Input : 4
A—
Output : A
Question :
A stock price is dynamic. Its value can change multiple times in a fraction of a second or remain
unchanged for several minutes. Analyzing the dynamics of stock price change can provide an
indication for forth coming uptrend or downtrend in that stock. One such indicator is simple
moving averages. Now, Harry wants to analyze the price trend of the stock on the basis of
moving averages (MA).
Let’s consider a moving average of 2-day and 4-day respectively. A 2-day moving average is
calculated by taking average of closing price of 2 consecutive days. A 4-day moving average is
calculated by taking average of closing price of 4 consecutive days. Now, according to experts
whenever a faster moving average curve (2-day MA) cuts the slower moving average (4-day MA)
from below, then it is an indication of uptrend in the stock. Similarly, whenever a faster moving
averages curve (2-day MA) cuts the slower moving average curve (4-day MA) from above, then it
is an indication of downtrend in the stock.
Help Harry in computing the number of uptrends and downtrends in the given time for which the
data is provided.
In this graph, there are three lines indicating stock closing price, moving average of two days and
four days .Now we can see that between 13th and 15th there is an intersection. It is known as
downtrend when moving average of fewer days is cutting downwards the more days moving
average and vice versa.
Note1 – There will be no day1 moving average for 2-day MA. Similarly there will be no day1,
day2, day3 moving average for 4-day MA. In general there will be no X-1, X-2, Y-1, Y-2, etc day
point for X-day and Y-day moving average curve.
Note2 – All the computation has to be accurate up to 6 digits after the decimal point.
Input
First line contains two space separated integers which are the moving average days X and Y.
Third line contains N space separated decimal values denoting the closing price of the stock for
N days.
Output
Print the total number of times the stock will give uptrend or downtrend.
Examples
Input : 3 5
11
4.55 5.4 5.65 5.4 5.2 4.85 4.95 5.05 4.9 4.9 4.95
Output : 3
Input : 2 4
14
Output : 4
Question :
Aman is a rich businessman who want to build a zoo. He wants to make enclosures for terrestrial
and aquatic animals. Terrestrial animals will be of two types, namely herbivorous and carnivorous
animals. So there will be three different enclosures.
Herbivores like Elephant, Deer are prime attractions. Similarly, Lion and Tiger are prime
attractions amongst carnivores. Finally, Dolphins and Shark are prime attractions amongst
aquatics for tourists.
Aman being a savvy businessman realizes that in order to minimize the cost of building the zoo
without compromising on the attractions, he has to decide how much area to allocate to each
animal type. Each animal type requires a certain area to thrive in. This in turn impacts the area
allocation, which in turn has cost implications.
Your task is to help Aman workout the mathematics such that the zoo building cost is minimized
subject to the following constraints:
For animals of a given type, the minimum area required is the same
There is also a maximum limit for the overall area allocated for each animal type
Exclude the essentials like pathways for tourists, from area and cost calculations
First line contains three space separated integers denoting the cost per square meter of building
the enclosure for each type of animals viz. herbivorous, carnivorous and aquatic respectively
Second line contains three space separated integers denoting the maximum area that can be
allocated to each type of animal viz. herbivorous, carnivorous and aquatic respectively
Next three lines, each will contain two space separated integers M and N, for each type of animal
viz. herbivorous, carnivorous and aquatic respectively, where M denotes minimum number of
animals of that type and N denotes minimum area required for that animal type
Last line contains an integer which represents the total area of land on which the zoo needs to be
built
Output
Single integer containing the minimum cost required to build the zoo.
Examples
55
15 5
10 10
500
Output : 837500
Explanation
·The cost of constructing the enclosure for herbivores is high. However, since we need to
accommodate 5 herbivores as per given constraints, a 25 sq. meter land will need to allocated
for the herbivores.
·Since the cost of constructing the enclosure for carnivores is cheapest we are able to allocate
them the maximum limit that we can allocate. Thus we are allocating 250 sq. meters for
carnivores.
·The remaining 225 sq. meters can thus be allocated to aquatics without violating any constraint.
·Thus the minimum cost of constructing the zoo adhering to all constraints is (25 * 10000 + 250 *
1000 + 225 * 1500) = 837500
Example 2
55
15 5
10 10
500
Output : 325000
Explanation
·Since the cost of constructing the enclosure for herbivores is cheapest we are able to allocate
them the maximum limit that we can allocate. Thus we are allocating 250 sq. meters for
herbivores.
·The cost of constructing the enclosure for aquatics is high. However, since we need to
accommodate 10 aquatics as per given constraints, a 100 sq. meter land will need to allocated
for the aquatic animals.
·The remaining 150 sq. meters can thus be allocated to carnivores without violating any
constraint.
·Thus the minimum cost of constructing the zoo adhering to all constraints is (250 * 100 + 150 *
1000 + 100 * 1500) = 325000
❤️
Just Follow sagar_mee_ on Instagram to get more career hacks and tips