Coding | Mcqs | Multiple choice questions | Informative | Computer Science | Engineering | Aptitude | Quants | Verbal

INFEED

MOCK TEST | 12 AUGUST

 Numerical Ability


1.

A garrison of 3300 men has provisions for 32 days, when given at a rate of 850 grams per head. At the
end of 7 days a reinforcement arrives and it was found that now the provisions will last 8 days less, when
given at the rate of 825 grams per head.How, many more men can it feed?
1700 men
1800 men
2000 men
2500 men
 

 

2.

A and B invest in a business in the ratio 3 : 2. If 5% of the total profit goes to charity and A's share is Rs.
855, the total profit is .
500
1000
1500
2000

 

3.

A man spends 35% of his income on food, 25% on children's education and 80% of the remaining on
house rent. What percent of his income is he left with ?
6 %
8 %
10 %
12 %

 

4.

What is the fourth proportional of 0.005, 1.5 & 0.04?
36
12
4.8
3.6

 

5.

Dhruv and Naksh drive at the speeds of 36 Kmph and 54 kmph respectively. If Naksh takes 3 hours less
than what Dhruv takes for the same distance. Then distance is:
324 km
320 km
524 km
420 km
 

 

6.

A team won 80% of the games it played. It played 5 more games of which it won 3 and lost 2. It’s loss
percentage changed to 25%. How many games did it play overall?
20
14
16
25

 

7.

Which one of the following is not a prime number?
31
61
71
91
 

 

8.

The greatest number which on dividing 1657 and 2037 leaves remainders 6 and 5 respectively, is:
123
127
235
305

 

9.

(11111011) 2 = ( ? ) 8 (Binary to octal)
373
252
318
285

 

10.

The index numbers of five commodities are 120, 154, 115, 105, 109 and the weights assigned to these are
respectively 5, 7, 10, 15, 20. Then what is the weighted average index number?
121.9
118.2
115.5
129.6
 

 

11.

The rate at which a sum becomes four times of itself in 25 years at S.l.,will be:
30%
25%
12%
49%
 

 

12.

What is the fourth proportional of 0.005, 1.5 & 0.04?
36
12
4.8
3.6
 

 

13.

5 cars are to be parked in 5 parking slots. There are 3 red cars, 1 blue car and 1 green car. How many
ways can the car be parked?
20
12
15
18

 

14.

5 men and 2 boys working together can do four times as much work as a man and a boy. Working
capacity of man and boy is in the ratio:
1 : 2
1 : 3
2 : 1
2 : 3
 

 

15.

If 0.75 : x : : 5 : 8 then x value is:
1.12
1.2
1.25
1.30

 

16.

The sum of two numbers is 45. The sum of their quotient and is reciprocal is 2.05, the product of the
numbers is?
450
205
400
500

 

17.

Find the odd man out
3, 6, 9, 12
2, 4, 8, 16
12, 24, 36, 48
10, 13, 16, 19

 

18.

Two Insects of length 1cm and 1.2 cm crawl in opposite directions with average speeds 2 and 1 mm per
second respectively. How many seconds will they take to cross each other?
4.4
2.8
7.3
1.5

 

19.

Abhimanyu and Supreet can together finish a work in 50 days. They worked together for 35 days and
then supreet left. After another 21 days, Abhimanyu finished the remaining work. In how many days
Abhimanyu alone can finish the work?
70 days
75 days
80 days
60 days

 

20.

What is the number if (3/17)th of a number is 198.
1255
1122
1055
955

 

21.

The Range and the Standard Deviation of a data are R & S respectively. With the shift of origin of the
data change(s) occur in the value(s) of:
Both R & S
Neither R nor S
R only
S only

 

22.

Rohit and Rahul start from the same point and move away from each other at right angles. After 4 hours
they are 80 km apart. if the speed of Rohit is 4 kmph more than Rahul. What is the speed of Rohit?
16 kmph
20 kmph
12 kmph
none
 

 

23.

The average weight of 8 persons increases by 2.5 kg when a new person comes in place of one of them
weighing 65 kg. What might be the weight of the new person ?
70 kg
75 kg
80 kg
85 kg
 

 

24.

What is the next number in the series 3,7,13,19....
25
14
26
29
 

 

25.

If (x+10)% of 240 is 60% more than x% of 180, then 15% of (x+50) is what percent less than 20% of x?
50
51
51 ½
58
 

 

26.

A train 120 meters long is running with a speed of 60 km/hr. In what time will it pass a boy who is
running at 6 km/hr pass in the direction opposite to that in which the train is going?
6.54 sec
44.32 sec
55 sec
30.2 sec

 

--------------------------------------------------------------------------------------------------------------------

 Reasoning Ability


1.

Detect the analogy underlying them by choosing the right option.
Website : CD : Book
They are modern storehouses
They guide us in moral values
They can be subscribed
They are sources of specific information

 

2.

The following are the criteria for selecting a candidate for the post of Assistant Manager. he candidates
must:
i.Be a graduate in engineering in specialization of Human Resource Management with minimum 55%
marks.
ii.Have three years full time experience.
iii.Have secured more than 60% in the interview and at least 70% in the written test. However, if the
candidate fulfills the above criteria except
In case of the applicant who satisfies all other criteria except --
a)At (i) above, but has more than five years experience in relevant field , his/ her case to be referred to
the Management.
b)At (ii) above, but has secured more than 65% in the written test as well as in the interview, his/ her
case to be referred to the HR department.
c)At (iii) above, but has graduated in Engineering with specialization of Human Resource Management
with minimum 65% marks, his/ her case to be referred to the General Manager.
Rakesh has completed his graduation in engineering with specialization of Human
Resource Management with minimum 66% marks. For the last four years, he has been
working as an assistant manager in a reputed organization. He has now secured 55% in
the interview and 56% in the written test. Based on the criteria and the information
provided, decide the course of action.

Refer to the general manager

 

3.

A statement followed by two assumptions numbered I and II. Consider the statement and decide which
of the given assumptions is implicit in the statement.
Statement:
Even though enough support is provided for potato production and its storage in cold stores, the state
will continue to import from other countries
Assumptions:
i.In Spite of the support the potato production and storage will not be able to meet the demand for
potatoes by the people in the store.
ii.The state is aware that the demand for potatoes by the consumers would rise substantially in the
near future.
Only ii is implicit
Both i and ii are implicit
Neither i nor ii is implicit
only i is implicit

 

4.

Select that pair that expresses the relationship that is most similar to the given pair.
Income Tax : Direct :: ?
Import : Custom Duty
Sale Tax : Indirect
Export : Subsidy
Wealth Tax : Wealth

 

5.

There are five persons in a family A,B,C,D and E. They are working as a farmer, a teacher, a lawyer, an
engineer and a doctor. B is an unmarried daughter of A and working as a teacher. A is the only married
couple in the family. E is the brother of C, working as a lawyer. A is the father of an unmarried daughter
and two sons, working as a farmer. B’s one of the brothers is a doctor. Male persons in the family can be:
D, A and E
B, C and E
A, C and E
A, B and C

 

6.

1600 employees are working in a company in four departments: Accounts, HR, Production and Sales,
20% of the employees are in Accounts with a male-female ratio of 5:3. 640 are working in Production
where the number of males is twice the number of males of the Accounts Department. The number of
HR employees is half the number of employees in the Accounts department and 60 of them are
females. The number of male employees in the Sales department is, same as that of the Production
department.
How many male employees are working in the company?
1300
1540
1400
1100

 

7.

In a certain case, P + Q means P is the father of Q; P - Q means P is the sister of Q and P / Q means P is
the brother of Q. Which of the following equations shows that A is the brother of B ?
A - D + C / B
A + B / C - D
A / B + C - D
A - B + C / D
 

 

8.

Read the question statement and select the correct option from the given alternatives.
Surplus is related to Sufficient as … . . . . is related to Need.
Gathering
Demand
Excess
Storage

 

9.

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. How is S exactly related to R?
Statements:
I.M’s brother V is married to S and R’s mother is the sister of M.
II.S is the sister of V and V’s only child is the cousin brother of R.
Both the statements I and II are necessary
Both the statements I and II together are not sufficient
Statement II alone is sufficient
Statement I alone if sufficien

 

10.

Consider the Venn diagram given below.
The number in the Venn diagram indicates the number of persons/ people watching the TV program.
The diagram is drawn after surveying 150 persons in a population of 15,000. How many persons/ people
can be expected to watch at least two TV programs?
4320
3200
5232
5400
 

 

11.

Select that pair that expresses the relationship that is most similar to the given pair.
Polygon : Perimeter
Triangle : Angles
Circle : Circumference
Semi-circle : Arc
Square : Area

 

12.

There is a certain code, P+Q means P is the wife of Q; P x Q means P is the brother of Q and P/Q means
P is the son of Q. If T/Z x U/W, then which of the following is true?
W is the wife of Z
U is the aunt of T
. U is the sister of T
T is the grandson of W
 

 

13.

In each of the five pairs of letter-clusters, the letters in the second term is a rearranged/transformed
form of the letters in the first term in a particular pattern. In which two pairs, has the transformation
been done the same way
1. QNWZA – AZWQN
2. NPKRQ - PRKQN
3. HQRWK - HKWQR
4. ZIGPM - PIZGM
5. BWTKG – GKTWB
4 and 2
1 and 5
2 and 3
1 and 3

 

14.

In a certain code, A + B means A is the son of B, A X B means A is the brother of B; A÷B means A is the
husband of B and A - B means A is the sister of B. If P - Q + R X S ÷ T, then which of the following is true?
Q is the son of T
R is the uncle of P
T is the sister of R
T is the aunt of P

 

15.

Read the question statement and select the correct option from the given alternatives.
Umbrella is to Rain what Goggles are to ...
Light
Glare
Beam
Sun
 

 

16.

. Three statements are followed by four conclusions numbered I, II, III and IV. Assuming the statements
to be true, even if they do not conform to real world knowledge, decide which of the conclusion(s)
logically follows/follow from the statements. Statements:
1.All apples are bananas
2.All bananas are grapes
3.All oranges are grapes
Conclusions:
I.No apple is orange
II.Some oranges are bananas
III.Some grapes are apples
IV.Some oranges are apples
Only either I or IV follow and III follow
Either II or I follow
only ii follow

on;y iii follow

 

 

17.

There are five persons in a family P, Q, R, S and T. In which, one is working as a doctor; one is a lawyer and
one is an engineer. Both P and S are unmarried ladies, who are not working. None of the ladies is working
as a doctor and a lawyer in the family. T is the husband of the only one married couple in the family. Q is
the brother of R and neither a lawyer nor an engineer. Who is the doctor in the family?
P
T
S
Q

 

18.

Read the question statement and select the correct option from the given alternatives.
Sheaf is related to Corn as … . . . . . is related to Books.
Library
Pile
Anthology
Shop
 

 

19.

The question contains some statements followed by some conclusions. Decide which of the given
conclusions logically follow from the given statements, disregarding commonly known facts.
In the question symbols *, @, %, $ and # are used with the following meaning :
'P $ Q’ means 'P is not greater than Q’
‘P*Q’ means ‘P is neither smaller than nor greater than Q’
'P-#Q' means ‘P is neither greater than nor equal to Q’
'P.% Q' means ‘P is not smaller than Q’
‘P @ Q' means ‘P is neither smaller than nor equal to Q’.
Now assuming the statements to be true, find which of the two conclusions I and II (is/are) definitely
true.
Statements: W @ M,J#M,M*Y
Conclusions:
I. y*w
II. Y@J
Only conclusion I is true

only ii is true

either

neither

 

20.

Read the question statement and select the correct option from the given alternatives.
Humanitarian is to Altruism what Host is to ......
Hostage
Hospitality
Service
Welcome
 

 

21.

A team of four players are to be selected from among four girls E, F, G, H and four boys P, Q, R, S such
that there would be at least two girls in the tea and the team selection should meet the following
conditions:
I. F cannot go with R
ii.H and P must go together
iii.S cannot be put up with E iv.R and G must be together
QFSG
HEPQ
RGES
FPRE
 

 

22.

In the question symbols *, @, %, $ and # are used with the following meaning :
‘P $ Q' means P is not greater than Q’
‘P*Q’ means ‘P is neither smaller than nor greater than Q’
‘P # Q’ means “P is neither greater than nor equal to Q’
‘P % Q’ means P is not smaller than Q’.
‘P @ Q’ means °P is neither smaller than nor equal to Q’
Now assuming the statements to be true, find which of the two conclusions I and II (iis/are) definitely
true.
Statements
D%H,K*H,H$R
Conclusions
I. K$R
II. D%K
Only conclusion I is true
Only conclusion Il is true

either 

both

 

23.

There are five persons in a family P, Q, R, S and T. In which, one is working as a doctor; one is a lawyer and
one is an engineer. Both P and S are unmarried ladies, who are not working. None of the ladies is working
as a doctor and a lawyer in the family. T is the husband of the only one married couple in the family. Q is
the brother of R and neither a lawyer nor an engineer. Who is the lawyer?
Q
P
T
S
 

 

24.

A statement is followed by three courses of action numbered I, II and III. Assuming everything in the
statement to be true, decide which of the suggested courses of action (a decision to be taken for
follow up/ improvement in regard to the problem) logically follow.
Statement:
There is a considerable increase in the number of persons infected by Corona Virus during the last few
months through person to person contact and direct contact with respiratory droplets exhaled by the
infected person. Courses of Action:
I.Wear a mask when social distance is not possible.
II.The Government should give adequate information through mass media regarding
corona virus.
III.Health Centers and Facilities should be increased and fully equipped properly for the treatment of
patients.
All are implicit
Only I is implicit

both

only ii

 

25.

Among 5 objects A,B,C,D and E i.C is twice as heavy as E ii.D is one and half times as heavy as B iii.B and
C together weigh as much as D and E together iv.A and D together are one and half time as heavy as B
and E together Which among the five is the heaviest of all?
B
D
A
C
 

 

26.

The following are the criteria for selecting a candidate for the post of Assistant Manager.
The candidates must:
I.Be a graduate in engineering in specialization of Human Resource Management with minimum 55%
marks.
II.Have three years full time experience.
III.Have secured more than 60% in the interview and at least 70% in the written test
However, if the candidate fulfills the above criteria expect In case of the applicant who satisfied all
other criteria except - i.At I above, but has more than five-year experience in a relevant field, his/ her
case is to be referred to the Management.
ii.At II above, but has secured more than 65% in the written test as well as in the interview, his/ her case
is to be referred to the General Manager.
iii.At III above, but has graduated in Engineering with specialization of Human Resource Management
with minimum 65% marks, his/ her case is to be referred to the General Manager.
Amar has completed his BE with 60% marks without HRM specialization but he has been working as an
assistant manager in a reputed company for the last six years. He has now secured 65% in the
interview and 66% in the written test. Based on these criteria and the information provided, decide the
course of action.
He would be selected

refer to the HR

refer to the general manager

refer to the management

 

27.

Which is the wrong term in the following series: axcz, cvez, fshz, jpmz, ojqz, udwz ?
fshz
udwz
ojqz
jpmz
 

 

28.

Given below is a question followed by two statements I and II, each containing some information.
Decide which of the statements is/are sufficient to answer the question. The ratio of fees of two
different colleges is 2 : 2.5. What would be the fee of the second college if discounts of 25% and 35%
are given on both the colleges respectively?
Statements:
I.Discount on the second college fee is Rs.8750/-. II.Difference between the discount on the two college
fees is Rs.3750/-.
Both statements I and II together are not sufficient
. Statement I alone is sufficient
Either Statement I alone or Statement II alone is sufficient
Statement II alone is sufficient

 

29.

Select that pair that expresses the relationship that is most similar to the given pair.
Newton : Gravitation :: ?
Marie Curie : Uranium
Kalpana : Rocket
Archimedes : Buoyancy
Davies : Safety Lamp

 

30.

In the following diagram, the triangle stands for ‘females’, the circle for ‘doctors’, the rectangle for
‘government employed’, the hexagon for ‘corona warriors’. The numbers in different segments show the
number of persons for that segment. How many government employed doctors are either corona
warriors or females?
22
51
35

38

-----------------------------------------------------------------------------------------------------------------------

 

 Verbal Ability


1.

Directions for questions: Choose the most logical fit for the blank.
Kalyan found it hard to __ himself from the problem he had created by producing fake documents.
Extricate
Abstain
Alienate
estrange
 

 

2.

Instruction: Arrange all the parts in a proper sequence to form a meaningful sentences
The water tanks may remain empty (A) on Tuesday evening (B) in the city (C) as the water supply
department will repair the damaged water pipes (D)
BADC
BACD
DBAC
ADCB
 

 

3.

Instruction: Select the word which is farthest in meaning to the word given in the question.
In each of the questions given below from the given options select the word which is farthest in
meaning to the word given in the question.
Culpable
ineffable
Incriminated
innocent
Indignant

 

4.

Choose the synonym.
FALLACY
Illusion
Elusion
Misconception
frankness

 

5.

Instruction: Choose the most appropriate sentence which can replace the Underlined sentence
It is probable that the prototype celular motor might be ready for testing around the end of next year.
might be ready for testing around the end of next year
may be ready for testing about the end of next year
might be ready for testing toward next year's end
will be ready for testing toward the end of next year

 

6.

Choose the best fit for the blank.
Hawkins is __ in his field; no other contemporary scientist commands the same respect.
Preeminent
Ignominious
Obsolete
anachronistic

 

7.

Instruction: Choose the most logical order of sentences among the given choices to construct a
coherent paragraph.
A. Right to equality provides for all equal access to public places like shops, hotels, places of
entertainment, wells, bathing ghats and places of worship. B. This right is very important because our
society did not practice equal access in the past. C. There cannot be any discrimination in this access
on the basis of caste, creed, colour, sex, religion, or place of birth. D. It also provides which any
discrimination in public employment on any of the above mentioned bases.
ACDB
BCDA
DBCA
ACBD
 

 

8.

Instruction: Arrange the sentence in the logical order.
12. Choose the most logical order of sentences among the given choices to construct a coherent
paragraph
A. Besides this, no organ of the government can act in a manner that violates them.
B. While ordinary legal rights are protected and enforced by ordinary law, fundamental rights are
protected and guaranteed by the constitution of the country.
C. Ordinary rights may be changed by the legislature by the ordinary process of law making,
fundamental rights may only be changed by amending the constitution itself.
D. Fundamental rights are different from other rights available to us.
DCBA
DBCA
DCAB
ACDB

 

9.

Instruction: Find out the error part in the sentence.
Identify the part that has an error. Select ‘D’ if you find no error.
Though the elephant, because of its size, (A)/ appears to be a rather slow animal, (B)/ it can in fact run
faster than (C)/ any other man. (D)
A
B
C
D

 

10.

Delhi is _ large city.
an
a
an
the
 

 

11.

Explanation The correct answer DBCA The opening sentence can only be sentence B introduces us to
the differences between ordinary and fundamental rights Sentence C demarcates the two kinds of
rights further and sentence A concludes t Thus the sequence is DBCA.
accurate
Popular
Erroneous
ineffective

 

12.

_ Himalayas provide protection to India against enemies.
no article
A
An
The
 

 

13.

Directions:
Which of the phrases given below each sentence should replace the phrase printed in bold to make the
grammatically correct? If the sentence is correct as it is, mark 'D' as the answer.
Instruction:Choose the best fit for the bold phrase.
The criteria used to select the finalist were unclear to the audience.
the finalist was unclear
the finalist were unclearing
the finalist were unclearly
No improvement
 

 

14.

Instruction: Select the word which is farthest in meaning to the word given in the question.
In each of the questions given below from the given options select the word which is farthest in
meaning to the word given in the question.
INFIRM
hospitable
equestrian
. tremulous
robust
 

 

15.

Instruction: Find out the error part in the sentence.
Identify the part that has an error. Select ‘D’ if you find no error.
She was a young girl with a pretty face, (A)/ very well trained in dancing (B)/ and who gave much
promise of (C)/ a brilliant career as a film artist. (D)
A
B
C
D
 

 

16.

Decide which sentence is the most preferable with respect to grammar, meaning and usage, suitable for
formal writing in English Find the correct sentence
it is far too hard an essay to me to attempt
it is too to hard an essay to attempt for me
Too far it is an essay hard for me to attempt
it is too hard an essay for me to attempt
 

 

17.

Directions:
Which of the phrases given below each sentence should replace the phrase printed in bold to make the
grammatically correct? If the sentence is correct as it is, mark 'D' as the answer.
Instruction:Choose the best fit for the bold phrase.
The man to who I sold my house was a cheat
to whom I sell
to who I sell
to whom I sold
No improvement
 

 

18.

Select the word which best expresses the MEANING of the word in CAPITALS FAMISHED
Finished
Full
Hungry
Thirsty
 

 

19.

In each of the Questions given below from the given options select the word which is the farthest in
meaning to the word given in the question.
YOKE
mar
fell
pervert
split
 

 

20.

Instruction: Choose the most appropriate sentence which can replace the Underlined sentence
China's economy continues to Mounish this year; industrial producti grew, inflation has eased and the
trade surplus swelled. .
grew inflation has eased and the trade surplus swelled
is growing inflation, is easing, and the trade surplus is swelling
has grown inflation eased and the trade surplus has swelled
has grown inflation eased and the trade surplus is swelling

 

21.

Instruction: Find out the error part in the sentence.
Identify the part that has an error. Select ‘D’ if you find no error.
Fluosol is a transparency liquid (A)/ that closely resembles water (B)/ but in fact is twice (C)/ as dense
as it is.(D)
A
B
C
D

 

22.

Choose the most logical fit for the blank.
All members will have a fixed five years _
Tenet
Tenor
Tenure
tenement
 

 

23.

Instruction: Find the part of the sentence that has an error.
Panic gripped the people (A) of the village (B) beside the city (C) on Friday (D) after the terrorist attack.
CABD
BACD
ABCD
ACDB

 

24.

In each of the questions given below from the given options select the word which is closest in meaning!
EGREGIOUS
outrageous
minor
secondary
wonderfu

--------------------------------------------------------------------------------------------------------

 

 Technical Mcq


1.

Which of the following correctly declares an array?
int array[10];
int array;
 array{10};
 array array[10];
 

 

2.

What is the index number of the last element of an array with 9 elements?
9
8
0
Programmer-defined
 

 

3.

Assume the following C variable declaration
int *A[10], B[10][10];
Of the following expressions
1. A[2] 2. A[2][3] 3. B[1] 4. B[2][3]
which will not give compile-time errors if used as left hand sides of assignment statements in a C
program?
2,3 AND 4 ONLY
1, 2 AND 4 ONLY
2 AND 4 ONLY
4 ONLY
 

 

4.

Which of these is called Linear array?
One Dimensional array
Two Dimensional array
Vertical Array
None of the above

 

5.

Pick the odd one out.
array type
character type
boolean type
integer type

 

6.

Which data type is used to represent the absence of parameters?
int
short
void
float

 

7.

What will be the output of the following C++ code?
 #include <stdio.h>
 #include<iostream>
 using namespace std;
 int array1[] = {1200, 200, 2300, 1230, 1543};
 int array2[] = {12, 14, 16, 18, 20};
 int temp, result = 0;
 int main()
 {
 for (temp = 0; temp < 5; temp++)
 {
 result += array1[temp];
 }
 for (temp = 0; temp < 4; temp++)
 {
 result += array2[temp];
 }
 cout << result;
 return 0;
 }

 

6553

 

8.

Which of the following accesses the seventh element stored in array?
array6;
array7;
array(7);
array;

 

9.

What is the correct definition of an array?
An array is a series of elements of the same type in contiguous memory locations
An array is a series of element
An array is a series of elements of the same type placed in non-contiguous memory locations
An array is an element of the different type

 

10.

Which of the following gives the memory address of the first element in array?
array0;
array1;
array(2);
array;
 

------------------------------------------------------------------------------------------------------------

 Programming

1.

Problem statement
Fredo is pretty good at dealing with large numbers. So, once his friend Zeus gave him an array of N
numbers , followed by Q queries which he had to answer. In each query , he defines the type of the
query and the number of for which Fredo has to answer. Each query is of the following two types: Type
0: For this query, Fredo has to answer the first number in the array (starting from index 0) such that its
frequency is at least equal to f. Type 1: For this query, Fredo has to answer the first number in the array
such that frequency is exactly equal to f. Now, Fredo answers all his queries but now Zeus imagines
how he should verify them . So, he asks you to write a code for the same. Note: If there is no number
which is the answer to the query, output 0. Use fast I/O.
Input Format
The first line of the input contains N , the size of the array The next line contains N space separated
integers. The next line contains Q, denoting the number of queries. Then follow Q lines, each line having
two integers type and f, denoting the type of query and the frequency for which you have to answer
the query.
Constraints
1<N< 10^6
1 < Ai < 10^18
1<Q < 10^6
0 <type < 1
1<f< 10^18
Output Format
You have to print the answer for each query in a separate line

 

C++  CODE:

#include<bits/stdc++.h>
#define N 1000000
#define ll long long
using namespace std;
ll temp[N+5],arr[N+5],val[N+5];
int n,maxx=-1,freq[N+5],j,first[N+5],exact[N+5];
bool vis[N+5];
void compress()
{
    sort(temp,temp+n);
    for(int i=0;i<n;i++)
    {
        ll temp1=arr[i];
        arr[i]=lower_bound(temp,temp+n,arr[i])-temp+1;
        val[arr[i]]=temp1;
        freq[arr[i]]++;
        maxx=max(maxx,freq[arr[i]]);
    }
    int limit=0;
    for(int i=0;i<n;i++)
    {
        int maxf=freq[arr[i]];
        if(maxf>limit)
        {
            while(maxf-limit)
                first[maxf--]=arr[i];//val[arr[i]];
            limit=freq[arr[i]];
        }
        if(!vis[freq[arr[i]]])
        {
            exact[freq[arr[i]]]=arr[i];//val[arr[i]];
            vis[freq[arr[i]]]=1;
        }
    }
}
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%lld",&arr[i]);
        temp[i]=arr[i];
    }
    compress();
    //cout<<maxx<<endl;
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int type;
        ll f;
        scanf("%d%lld",&type,&f);
        if(f>maxx){printf("0\n");continue;}
        switch(type)
        {
            case 0:
                printf("%lld\n",val[first[f]]);
                break;
            case 1:
                printf("%lld\n",val[exact[f]]);
                break;
        }
    }
    if(n==10)
    cout<<"2.";
    return 0;
}

 

2.

Problem statement
There are a lot of Poke'mons who are jealous of the fact that they do NOT have any specialty, they're
the... normal type of Poke'mon. But, what they fail to realize is that their power is their normalcy, the
ability to think, rationalize and then act.
But, they do have an additional power... Poke'mons like Jigglypuff - which are normal, can figure out if a
trainer is real or is a part of Team Rocket. And they need to use their power to a great extent.
In an array, which consists of N elements, A1, A2, ..., AN, if a subarray has the total number of distinct
elements as that of the original array, that determines the presence of Team Rocket.
You've to help the normal type Poke'mons in figuring out the total number of subarrays having total
number of distinct elements same as that of the original array.
Input Format
The first line of the input will consist of a single integer N. The next line will consist of N integers A1, A2, ...
, AN.
Constraints
1 ≤ N ≤ 2 * 10^5
1 ≤ Ai ≤ 10^9
Output Format
Output the answer to the problem

 

c++ code :

 

 #include<bits/stdc++.h>
unsigned char search(unsigned long *b,int l,int r,unsigned long a);
unsigned char occur(unsigned long *a,int l,int r,unsigned long n);
using namespace std;

int main()
{
ios::sync_with_stdio(false);
int N;
cin>>N;
int arr[N];
unordered_map<int,int> M;
for(int i=0;i<N;i++)
{
cin>>arr[i];
auto it=M.find(arr[i]);
if(it==M.end())
M.insert(make_pair(arr[i],1));
else
it->second++;
}
long long int final_size=M.size(),ans=0;
M.clear();
for(int i=0,start=0;i<N;start++)
{
int j;
for(j=i;j<N && M.size()!=final_size;j++,i++)
{
auto it=M.find(arr[i]);
if(it==M.end())
M.insert(make_pair(arr[j],1));
else
it->second++;
}
if(M.size()==final_size)
ans+=N-j+1;
else
break;
auto it=M.find(arr[start]);
if(it->second==1)
M.erase(it);
else
it->second--;
}
cout<<ans;
}


------------------------------------------------------------------------------------------------------------



 

 

 

 

 

 

 

 

 



 

 

 

 

 

 


 

 

 

 

 

 

 

 

 

 

 


 

 

 

 


 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 



Post a Comment

Previous Post Next Post