Null 4
Null 4
Question 2:
A number 452p36 is such that it is divisible by 36. What can the value of p^2 be?
Options:
a. 36
b. 25
c. 49
d. 16
Answer:- Option C the value of p=7 and p^2=49
Question 3:
Question 4:
Let x be the least number which when divided by 12,15,18,20,27 and 30, the remainder in each
case is 1 and x is a multiple of 47. The sum of the digits of x is:
Options:
a. 13
b. 11
c. 9
d. 10
Ans:- d) 10
Options
a. 30%
b. 65%
c. 50%
d. 40%
Question 6:
Question 7: The expenditure of Rashmi is equal to 225% of her savings. If her income increases
by 20% and the expenditure increases by 40%, then her savings will .
Options
a. Decrease by 25%
b. Decrease by 20%
c. Increase by 25%
d. Increase by 33 ⅓ %
Answer: Option A
Question 8:
A business lady bought 400 handbags. She sold 100 of them at a profit of 20% and the rest at
10% profit. Find the overall profit percentage.
Options:
a. 12.5%
b. 16.75%
c. 19.75%
d. 11.25%
Answer:- 12.5%
years?
a. Rs. 6194.4
b. Rs. 5575.4
c. Rs. 6098.4
d. Rs. 5447.4
Answer -
Answer: Option D
Question 11: An electronics item dealer can earn a profit of 5%, even after allowing a 30%
discount. He wanted to clear his old stock, so he offered a scheme of three successive
discounts of 12%. What could be his minimum profit % approximately?
Options
a. 2
b. 4
c. 1
d. 3
Answer: Option A
Question 12: A shopkeeper sells an item at Rs. 368.55 after giving a discount of 25% on its
labelled price. Had he not given the discount, he would have earned a profit of 17% on its costprice.
What is the cost price (in Rs) of the item?
a. 400
b. 450
c. 380
d. 420
Answer - Option D
Options
a. 125
b. 101
c. 50
d. 150
Answer:- Option C
Answer- Option C
Question 15:
Sachin borrows Rs,53000 from a moneylender and promises to pay him the total amount after 6
months at the rate of 20 percent per annum simple interest.Due to non payment after 6 months,
the moneylender calculates the simple interest at 30 percent per annum on the principal amount
for the overdue period. Find the total amount to be paid by Sachin after 1 year.
Options:
a. Rs.68570
b. Rs.60420
c. Rs.60000
d. Rs.61760
Question 16:
A trader buys 120 m cloth at Rs 125 per metre. He sells 40% of it at a gain of 10% and 33 % of
the remaining cloth at a gain of 15%. At what percent should he sell the remaining cloth so as to
gain 25% in the entire transaction?
a. 42
b. 30
Answer: Option d
Question 17:
If and y = ,
then the value of (x divided y) is
Option
A. 2 1/6
B. 3 1/3
C. 6 2/3
D. 2/15
Answer: Option A
Question 18:
The cost price of an article is Rs. X. Ambuj marks a new price on it and after allowing a discount
of 20% on the newly marked price, he sells it for Rs. 1.2X. He sells a second article whose
marked price is twice the marked price of the first article, at a discount of 50%. Find the ratio of
the selling price of first article to the second article.
a. 4:5
b. 5:3
c. 3:5
d. 2:3
Answer - Option A
Question 19.
What is the area of the triangle ABC, where AB=10 cm, BC=10 cm and CA=16 cm?
a.
b.
c.
d. 48 cm2
Answer- Option D
Question 20:
Two persons were approaching each other at 12 km/hr and 24km/hr respectively. A train moving
in the same direction as the faster man took 25 seconds to cross him and 15 seconds to cross
the other one. Find the speed of the train(in km/hr).
Answer: Option C
Question 21:
b. 9 / 13
c. 16 / 3
d. 9 / 5
Answer - Option B
Question 22:
What is the value of 'k' in the expression given below?
Option:
A. 121.2
B. 123.5
C. 124.6
D. 115.7
Answer- Option A
Question 23:
In 75% of the time that B takes to do a piece of work, A does half the work. Together they take
18 days to complete the work. C alone can complete the same work in 24 days. All the three
started the work together but B left 5 days before the completion of the work. In how many days
was the whole work completed?
Options:
a. 12
b. 15
c. 10
d. 16
Question 24:
The speed of a boat upstream is 40% less than the speed of the boat downstream. It takes 13.5
hours to go 120 km downstream and 90 km upstream. How much time (in hours) will it take to go
90km downstream and 120 km upstream?
TCS – NINJA – PREPARATORY KIT PAGE - 6
d. 14
Question 25:
The value of is
Option:
A. 0.001
B. 0.0001
C. 0.01
D. 0.1
Answer - B.0.0001
Question 26:
Let x, y, and z be the mean, median and range, respectively of the following data:
10, 7, 12, 21, 37, 14, 19, 28, 18, 12, and 42.
What is the value of (x + y - z)?
a. 2
b. 4
c. 7
d. 3
Answer: Option d
VERBAL ABILITY
Question 1:
One part of the sentence below may contain an error. Identify the part. If there is no error
choose “No Error”
A sociologist study the ways in which people live together, raise their family and follow
community structures and customs.
Options:
a. No error
b. A sociologist study the ways in which
c. and follow community structures and customs.
d. people live together, raise their family
a. In spite of a
b. De spite of a
c. Although
d. Even though
Answer: A
Question 3: One part of the sentence below may contain an error. Identify the part. If there isno
error choose ‘No Error’
Either of the two candidates who have filed for the nomination are suitable for the position.
Options
a. No error
b. Either of the two candidates
c. are suitable for the position
d. who have filed for the nomination
Answer: D
Question 4: One part of the sentence below may contain an error. Identify the part. If there is
no error choose ‘No Error’
Options
a. No Error
b. carry these books
c. May you
d. for me, please?
Answer: C
Question 5:
One part of the sentence below may contain an error. Identify the part. If there is no error
The Prime Minister will announce the scheme if the Cabinet will approve it.
Options:
a. if the Cabinet will approve it.
b. announce the scheme
c. The Prime Minister will
d. No Error
Answer: a
Question 6: Read the following sentence and fill in the blank by selecting the appropriate
option:
It is not easy to _ __ _ the profoundness of a mother’s love for her child
Options
a. Evaluate
b. Fluctuate
c. Equate
d. Overestimate
Answer: A
Question 7:
One part of the sentence below may contain an error. Identify the part. If there is no error
choose ‘No Error’
Answer: B
Question 8:
For the four sentences (S1 to S4) paragraph below, sentence S1 and S4 are given. From the
options P, Q, and R choose the appropriate sentences for the given passage:
S1: Banana trees live for about six years, but each stem of the tree only lives long enough to
produce fruit.
a. QR
b. RP
c. RQ
d. PQ
Answer - RP
Answer - to
Question 11:
The following sentence pair can be combined into one better sentence. Choose the option
that combines the two sentences best without changing the meaning.
The father was happy on his son’s birthday. The son was feeding hundred poor men instead of
throwing a birthday party.
Answer:d
Question 12:
Which of the following sentences uses formal language.
a. Why do you crib so much?
b. They have submitted Proposal
c. I love mumbai. It is alive and kicking
d. He hasn’t changed a bit
Answer: B
Question 13.The following sentence can be revised into one better sentence. Choose the
sentence that is the best revision.
Answer: A
One 1. _ that can benefit immensely from solar power is manufacturing. Companies in
this industry utilise a significant amount of electricity during their production processes. Large
flat roofs of factories are ideal for 2. _ solar panels. The solar panels should face
south to maximise sunlight exposure.
Options
a. 1(D) 2(C)
b. 1(B) 2(D)
c. 1(C) 2(A)
d. 1(A) 2(B)
Answer: B
Question 15:
Read the passage given below and answer the questions that follow
NOTE: After selecting your response to the sub question, you must click ‘SAVE AND
NEXT’ button to move to the next sub question
The Sumatra earthquake and tsunami are considered to be an eye-opener for India, December
26 marks the 16th anniversary of the massive Indian Ocean tsunami. On this day, a 100 foot
high tsunami triggered by an earthquake from under the Indian Ocean hit South Asia. The
epicentre of the earthquake was near Sumatra, Indonesia an it hit Thailand, Sri Lanka, India.
Indonesia. A tsunami researcher and forecaster, Vasily Titov cites that there are some largest
faults in the world and they're all underwater. He added that the tsunami waves could be seen
like a large pebble falling in the ocean causing mega ripples. Learning from the unprecedented
natural disaster that led to such heavy damage to life and property, the Ministry of Earth
founded the Indian Tsunami Early Warning System (ITEWS) at the Indian National Centre for
Ocean Information Services (INCOIS), Hyderabad in October 2007. Scientists in India are
now able to predict and project movements in Indian ocean through real-time seismic
monitoring systems. A community performance-based programme known as Tsunami Ready
has also been started by the Intergovernmental Oceanographic Commission (IOC) of
UNESCO to promote tsunami preparedness by activity involving the public, community
leaders and national and local emergency management agencies, India is the first country to
establish an early warning system for tsunami detection, while Odisha is the first state in the
Answer: a
Question 16:
Read the passage given below and answer the questions that follow
NOTE: After selecting your response to the sub question, you must click ‘SAVE AND
NEXT’ button to move to the next sub question
The Sumatra earthquake and tsunami are considered to be an eye-opener for India, December
26 marks the 16th anniversary of the massive Indian Ocean tsunami. On this day, a 100 foot
high tsunami triggered by an earthquake from under the Indian Ocean hit South Asia. The
epicentre of the earthquake was near Sumatra, Indonesia and it hit Thailand, Sri Lanka, India.
Indonesia. A tsunami researcher and forecaster, Vasily Titov cites that there are some largest
faults in the world and they're all underwater. He added that the tsunami waves could be seen
like a large pebble falling in the ocean causing mega ripples. Learning from the unprecedented
natural disaster that led to such heavy damage to life and property, the Ministry of Earth
founded the Indian Tsunami Early Warning System (ITEWS) at the Indian National Centre for
Ocean Information Services (INCOIS), Hyderabad in October 2007. Scientists in India are
now able to predict and project movements in Indian ocean through real-time seismic
monitoring systems. A community performance-based programme known as Tsunami Ready
has also been started by the Intergovernmental Oceanographic Commission (IOC) of
UNESCO to promote tsunami preparedness by activity involving the public, community
leaders and national and local emergency management agencies, India is the first country to
establish an early warning system for tsunami detection, while Odisha is the first state in the
country to get Tsunami Ready recognition.
The Sumatra earthquake and tsunami are considered to be an eye-opener for India. Which of
the following statements justifies this?
Options:
a. After the unprecedented earthquake, India became the first country to establish an
TCS – NINJA – PREPARATORY KIT PAGE - 13
Question 17:
Read the following sentence and select the most appropriate option to fill in the blanks:
a. Ingenuous, isolation
b. Extrovert, gathering
c. Ambivert, loneliness
d. Introvert, solitude
Answer - D
Question 18: For the four sentences (S1 to S4) paragraph below, sentence S1 and S4 are
given. From the options P, Q, and R choose the appropriate sentences for the given passage:
S1. Research suggests that the price is of products and advertisements motivate consumers to
try out new products
S2.
S3.
S4. Above all, the credibility of the source of the advertised messages affects the consumers
judgement of performance risk associated with the product's risk.
Answer: RQ
Question 19:
For the four sentences (S1 to S4) paragraph below, sentence S1 and S4 are given. From the
options P, Q, and R choose the appropriate sentences for the given passage:
Options
a. PQ
b. PR
Answer: PQ
Question 20: There are many hobbies that one can practice for leisure..
Travelling for exploration can be one of them.1._ _hobbies one can practice
nevertheless is the most expensive too , as now a days the airfares are 2. .However ,
one can still explore cheaper options and nearby destinations for travelling.
Blank1. A. nourishing B.glorifying C. dissatisfying D. fulfilling
Blank 2. A. distributing B.refunding C.decreasing D.skyrocketing
a. (1) - A, (2) - B
b. (1) - B , (2) - C
c. (1) - D , (2) -D
d. (1) - D , (2) - A
Answer - C
Most of the earth is covered with undrinkable water. Oceans cover 70% of Earth’s surface
and account for about 97% of all water. The average salt content of ocean water is 35 parts
per thousand, which is about 120 million tons of salt per cubic mile of seawater.
Where does all the salt come from? It comes mostly from the land. As rain forms and falls
through the air, it accumulates carbon dioxide from the atmosphere and becomes slightly
acidic. It then flows over the land, necrociting rocks and picking up small amounts of salt and
other dissolved minerals. At this point, the water is still fresh and drinkable. Once this water
flows into the ocean, some of the dissolved minerals are removed from it by biological
processes, but the salt remains. Additional salt is contributed by underwater hydrothermaland
volcanic activity.
The idea that salt was gradually deposited in the sea by rivers was first suggested by Edmond
Halley. He proposed that the salinity of seawater could be used to determine the age of the
ocean. Based on this theory Physicist Johnny Jolly came up with an estimate of 90 million
years, which was later calculated to be 4 billion years with the use of advanced technology.
Hailey’s scheme had a flow. He failed to account for the fact that some sea salt gets concealed
in the form of mineral deposits on the seafloor.
Question: Why was John Jolly’s estimate of the age of the oceans revised?
Options
a. Because the new estimate was calculated after a substantial time
b. Because John Jolly’s estimate accounted for the salt deposited on the seafloor
c. Because the precision of advanced technology used yieldied a far greater age
d. Because John Joly did not follow Hailey’s scheme to perform calculations.
Answer - C
Question 22:
Read the following passage and fill in the blanks by selecting the most appropriate option:
No one knows for sure what _1_ _ yawning serves. Some say it is a sign of stress, and
others say it is an indication of boredom. Scientists usually thought it was meant to increase
the amount of oxygen in the body or to 2__ excess carbon dioxide from the body. But
they did not explain why, when one person in a room yawns, the others start yawning too.
b. (1) - A, (2) - D
c. (1) - C, (2) - B
d. (1) - B, (2) - C
Answer - C
“Horror movies” have a huge fan base around the world including children _ they
believe that the ghastly faces of the ghost, eerie sound effects and chilly background settings
of the horror movies create permanent impressions on a child’s mind _ Later in life, it
might happen that these impressions may come to haunt the imagination whenever one is
subjected to any fearful emotions.
A. Horror movies give an adrenaline rush to the viewer, hence they are loved so much.
B. However some psychologists are of the opinion that children should not be exposed to
horror movies at all.
C. Watching such ghastly faces might give an adrenaline rush in the beginning but those
impressions are forgotten,
a. (1)-B, (2)-C
b. (1)-C, (2)-B
c. (1)-C, (2)-A
d. (1)-A, (2)-C
Answer: A
Question 24:
The following sentence pair can be combined into one better sentence. Choose the option
that combines the two sentences best without changing the meaning.
Options:
a. You cannot drive a vehicle unless you have a driving licence.
b. You cannot drive a vehicle because you have a driving licence
c. You cannot drive a vehicle, but you should have a driving licence
Answer: a
REASONING ABILITY
Question 1. Which is the wrong term in the following series:
BEG,DGI,GJL,KMP,PSU
1. DGI
2. PSU
3. GJL
4. KMP
Question 2.
Which is the wrong term in series
Cab, gef, ljk, rpq, xvw
Option
A. rqp
B. ljk
c. xvw
C. gef
Question 3:
Six movies are played on six consecutives days of week, starting from monday. Rambo is
played after Diago. Noorie is telecast between Diago and Akira. Blayed is played immediately
after Hungamma but before Akira. Which movie is played on tuesday?
A. Akira
B. Noorie
C. Blade
D. Hungamma
Answer - Option C
Question 4:
In each of the four pair of letter-clusters, the letter in the second term are a rearranged/
transformed form of the letters has been put together in a particular pattern. In which two pairs,
has the transformation been done in the same way?
a. LOCK - QYAN
Answer: Option A
Question 5:
Which of the option figures would come next in the following figure series
Option
A.
B.
C.
D.
Question 6:
In a certain code if :
A-B means A is wife of B.
A/B means A is brother of B.
A+B means A is daughter of B.
A*B means A is son of B.
Answer - Option - 4
Question 8: In Ipl 2020, Sachin expected that Mumbai Indian wins more than 3 but less than 7.
Veeru expected that Mumbai indians wins more than 5 but less than 8 matches. If the both of
them are correct then how many matches can Mumbai Indians win?
A. 6
B. 4
C. 7
D. 5
Answer - Option - A- 6
Question 9:
Given below is a question followed by three statements I,II and III each containing some
information. Decide which of the statement(s) is/are sufficient to answer the question
Six persons A, B, C, D, E and F are sitting around a circular table facing towards centre. Who
sits second to the right of D
I. C and D are immediate neighbours and C is sitting opposite B
TCS – NINJA – PREPARATORY KIT PAGE - 20
Question 10:
A statement is followed by three assumptions numbered I and II. Consider the statement and
decide which of the given assumption(s) is/are implicit in the statement.
Statement
A trader in XYZ city said, “ We will offer a 5% discount on the total purchase of ration, if the
buyer shows the certificate of being vaccinated against the deadly virus.”
Assumptions:
I. The traders in other cities will also take up similar initiatives.
II. People in general are very neglectful in getting vaccinated.
III. The trader intends to sell a huge stock of ration lying in his shop for a long period of
time.
Options:
a. All I, II and III are implicit.
b. Only II is implicit.
c. Only III is implicit.
d. Only I and II are implicit.
Answer - Option - A
A. L is wife of A
B. H is daughter of A
C. S is son of L.
D. S is the son of law of T
Question 12: Find the WRONG term in the letter cluster series given below.
RPF, WUK, TRH, YMW, VTJ
A. WUK
B. VTJ
C. YMW
D. TRH
Answer: Option C.
Question 13:
In a certain code:
Question 14:Given below is a question followed by two statement I, and II each containing some
information. Decide which of the statement(s) is/are sufficient to answer the question
Six persons named Ishi, Jolly kitty, Dinky, Emi and Ferry are sitting in a row facing North, but not
necessarily in the same order. Who is sitting in the right end of the row ?
I. Jolly is sitting exactly between Dinky and Ishi , who is sitting exactly between Kitty and
Ferry.
II. There are exactly two persons sitting between Kitty and Ferry, who is to the left of Ishi .
Dinky is sitting to the immediate right of Kitty and is to the immediate left of Jolly.
Answer: Option C
Answer - Option - A
Question 16:In each of the four pairs of cluster , the letter in the second term are in
rearranged/transform form of the letter from (not clear)
[A] MASTER-RTSMAF
[B] POSTAL- LTOPSA
[C] HASTEN - NTSAHE
[D] FATHER - RHAFTE
1. B and C
2. B and D
3. A and C
4. A and C
Answer: Option C
Question 17:
If P, Q, R, S, T, U,V, W and X are nine industries. R is 2km to the east of Q. P is 1km to the north
of Q and W is 2km to the south of P. V is 1km to the west of W, while S is 3 km to the east of V.
U is 2km to the north of V. X is situated exactly between Q and R while T is exactly between W and
S.
What is the distance between P and U?
Options:
a. 3km
b. 2km
c. 1.41km
d. 1km
Answer: Option d - 1 km
Answer - Option - B
Answer: Option C
Question 20:
Select the option that is related to the third figure in the same way second figure is related to the
first figure.
a.
b.
c.
d.
Answer - Option A
Question 21.
Given below is a question followed by two statements, I and II each containing some
information. Decide which of the statement(s) is/are sufficient to answer the question.
Options:
a. Statement II alone is sufficient.
b. Both the statements I and II are necessary.
c. Statement I alone is sufficient.
d. Both the statements I and II together are not sufficient.
Answer: Option C
Answer: Option C
Question 23:Given below is question followed by three statements 1,2 and 3. Each containing
some information.Decide which of the statements is correct:
Six persons A,B,C,D,E and F seating around a circular table facing to centre.Who sits second to
the right of D.
1. C and D are immediate neighbour and C is sitting opposite to B.
2. A is not a neighbour of E, but is a neighbour of B.
3. D is not a neighbour of A,but is a second to the right of F.
a. Only 1 and 2
b. Only 1 and 3
c. All three together
d. Only 2 and 3
Answer - Option B
Question 24:
In the following figure, Hexagon represents Animals, Triangles Represents Pets and Circle
represents wild.Which set of numbers represent wild which are both pet and animals?
a. 2
b. 3
c. 1
d. 5
Answer: Option D
Question 25:
Every year 20% of the employees leave a company between 1st and 15th december for other
jobs. The company recruits 100 new employees every month of january. 276 employees left the
company by 15th december 2020.How many employees were there in the company in the last
week of december.
A. 1600
B. 1750
Answer: Option C
Question 26:.
Following is the data regarding the number of students in each section out of 3 sections: A,B
and C in standards; V, VI and VII.
There are 440 students in total in the 3 standards. In standard V, 40% of the students are from
section B and 40 students are from section A.
The ratio of the number of section B students in standard V to that in standar VI is 10:11.
In standard VI, there are 4 more students in section C than in section A,
There are 160 students in standard VI.
There is 1 more student in section C, of standard V than in section C of standard VI.
The average number of section A and section C students in standard VII is 43.
The ratio of total number of section A students to total number of section C students is 4:5.
For the 3 standards combined, what is the difference between the total number of section B
students and the average number of section A and C students?
Options:
a. 35
b. 30
c. 40
d. 45
Answer:
Question 27:Given below is question followed by two statements 1 and 2. Each containing some
information.Decide which of the statements is correct:
Answer: Option D
Question 28: Given below is the question followed by two statements I and II, each
containingsome information .Decide which of the following statement(s) is/are sufficient to
TCS – NINJA – PREPARATORY KIT PAGE - 27
Answer: Option C
Question 29: The production by a company ‘xyz’ in the year 1997 was double than that in the
year 1995 where the production in 1995 was 30000. The production in the years 1996, 1998,
1999 and 2000 were 46000,70000,50000 and 80000 respectively.
For how many years was the production more than the average production of the given years?
Options:
a. 2
b. 4
c. 1
d. 3
Answer: Option D
Question 30:
Which of the following numbers will appear on the face opposite to the face with number 2?
a. 4
b. 3
c. 5
d. 6
Answer: Option D
A. 1
B. 0
C. True
D. False
Ans:- 1
A. 8
B. -8
C. 16
D. -16
Ans:- c)16
Question 4:
#include <stdio.h>
int function1(int,int);
int main()
{
int a=10,b=10;
printf("%d",function1(a,b));
return 0;
}
int function1(int a , int b)
{
return(a-(a==b));
}
A. 0
B. 9
C. Not visible
D. Not visible
Ans:- B) 9
Question 5:
Question 7:
What will be the output of the following code
#include <iostream>
using namespace std;
int main()
{
int a=5,b=0,c=15,d=20,e=0;
while(a<b)
e=(a+c)*d+c;
cout<<e<<""<<b;
return 0;
}
A. 420 0
B. 0 0
C. 420 10
D. 0 10
Ans:- B) 0 0
TCS – NINJA – PREPARATORY KIT PAGE - 31
Question 9:
What is the output of the below code?
#include <iostream>
using namespace std;
int main()
{
int num=5,i;
long int result=1;
for(i=num;i>(num-num);i--){
result=result*i;
}
printf("%d",result);
return 0;
}
A. 0
B. 60
C. 120
D. Compile error
Ans:- 120
Question 10: How many iterations are required for searching the element 36
using binary search for the below set?
2,6,12,23,25,33,35,36,36,36,43,47,52,63,65,79
A) 6 iterations
B) 5 iterations
C) 7 iterations
D) 1 iterations
Ans: 1 iteration (Length=16, so 16/2=8, 8 element=36, found. Stop iteration)
Example 1:
Input :
5 -> Value of T
[7,0,5,1,3] -> E[], Element of E[0] to E[N-1], where input each element is separated by new line
[1,2,1,3,4] -> L[], Element of L[0] to L[N-1], while input each element is separate by new line.
Output :
8 -> Maximum number of guests on cruise at an instance.
Explanation:
1st hour:
Entry : 7 Exit: 1
No. of guests on ship : 6
2nd hour :
Entry : 0 Exit : 2
No. of guests on ship : 6-2=4
Hour 3:
Entry: 5 Exit: 1
No. of guests on ship : 4+5-1=8
Hour 4:
Entry : 1 Exit : 3
No. of guests on ship : 8+1-3=6
Hour 5:
Entry : 3 Exit: 4
No. of guests on ship: 6+3-4=5
Hence, the maximum number of guests within 5 hours is 8.
Example 2:
Input:
4 -> Value of T
[3,5,2,0] -> E[], Element of E[0] to E[N-1], where input each element is separated by new line. -
[0,2,4,4] > L[], Element of L[0] to L[N-1], while input each element in separated by new line
Explanation:
Hour 1:
Entry: 3 Exit: 0
No. of guests on ship: 3
Hour 2:
Entry : 5 Exit : 2
No. of guest on ship: 3+5-2=6
Hour 3:
Entry : 2 Exit: 4
No. of guests on ship: 6+2-4= 4
Hour 4:
Entry: 0 Exit : 4
No. of guests on ship : 4+0-4=0
Hence, the maximum number of guests within 5 hours is 6.
Constraints:
1<=T<=25
0<= E[i] <=500
0<= L[i] <=500
Solution in Java:
import java.util.*;
class Solution
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
int e[]=new int[t];
int l[]=new int[t];
for(int i=0;i<t;i++)
l[i]=sc.nextInt();
int max=0,sum=0;
for(int i=0;i<t;i++)
{
sum+=e[i]-l[i];
max=Math.max(sum,max);
}
System.out.println(max);
}
}
Question 2:
At a fun fair, a street vendor is selling different colours of balloons. He sells N number of
different colours of balloons (B[]). The task is to find the colour (odd) of the balloon which is
present odd number of times in the bunch of balloons.
Note:
If there is more than one colour which is odd in number, then the first colour in the array which is
present odd number of times is displayed. The colours of the balloons can all be either upper
case or lower case in the array. If all the inputs are even in number, display the message “All are
even”.
Example 1:
7 -> Value of N
[r,g,b,b,g,y,y] -> B[] Elements B[0] to B[N-1], where input each element is sepārated by ṉewline.
Output :
r -> [r,g,b,b,g,y,y] -> “r” colour balloon is present odd number of times in the bunch.
Explanation:
From the input array above:
r: 1 balloon
g: 2 balloons
b: 2 balloons
y : 2 balloons
Output :
b-> ‘b’ colour balloon is present odd number of times in the bunch.
Explanation:
From the input array above:
a: 2 balloons
b: 3 balloons
c: 4 balloons
f: 1 balloons
Here, both ‘b’ and ‘f’ have odd number of balloons. But ‘b’ colour balloon occurs first.
Constraints:
3<=N<=50
B[i]={{a-z} or {A-Z}}
Solution in Java:import java.util.*; class Solution
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
char arr[]=new char[n];
for(int i=0;i<n;i++)
arr[i]=sc.next().charAt(0);
int lower[]=new int[26];
int upper[]=new int[26];
for(int i=0;i<n;i++)
{
TCS – NINJA – PREPARATORY KIT PAGE - 36
}
if(flag==true)
System.out.println(ch);
else
System.out.println("All are even");
}
}