100% found this document useful (1 vote)
736 views80 pages

Codevita PDF

TCS CodeVita is a coding competition with three rounds of increasing difficulty. It tests coding ability through online rounds and an in-person grand finale. The document provides details on eligibility, dates and locations for each round, as well as sample problems and topics that may be covered.

Uploaded by

Jashan Bansal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
736 views80 pages

Codevita PDF

TCS CodeVita is a coding competition with three rounds of increasing difficulty. It tests coding ability through online rounds and an in-person grand finale. The document provides details on eligibility, dates and locations for each round, as well as sample problems and topics that may be covered.

Uploaded by

Jashan Bansal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 80

TCS CodeVita, is a coding centric competition, it only tests one's coding ability.

This competition has three rounds where each


round is more difficult than the previous one. The three rounds are

1) The Pre- Qualifier Round:


In this round, there will be a 24 hours contest window and each participant is provided with 6 hours of time to solve the questions.
Pre-Qualifier round is done in India as well as the rest of the world separately. This season there will be two zonal rounds in INDIA
for Pre-Qualifier. A participant will be tagged to one of the two zonal rounds and you can choose any of the 6 hours to start your
challenge.

Starts: 10th Jul, 2020, 09:30 UTC


Ends: 25th Jul, 2020, 09:30 UTC
Takes Place Online

Programming languages available are:C, C++, C#, Java, PHP, Perl, Python, Ruby

2) The Qualifier Round:


This season Qualifier Round (Round 2) would happen after the completion of all the Pre-Qualifier rounds across the world. Top
performers from the zonal rounds globally will move into this round. Each participant will be provided with 6 hours of time to solve
& complete this round.

Starts: 7th Nov, 2020, 09:30 UTC


Ends: 8th Nov, 2020, 09:30 UTC
Takes Place : Online

3) Grand Finale:
This round will be held in one of the TCSL offices in India. Top 3 contestants will be declared as winners of the contest. The grand
finale is tentatively scheduled to be conducted in the last week of February 2021.
Each round is followed by an interview, you can proceed to the next round, only after you have cleared the interview. The interview
is conducted on the basis of your previous round only, where they ask you questions based upon the answers and techniques which
you have used in the previous round. There is no surety that you will get qualified for the next round if you have solved all the
questions, or will not be qualified for the next round if you have solved only 3 questions, it is solely based upon the programming
techniques you are using, and your interview.

There is no particular syllabus as defined by TCS CodeVita Team, however, you can expect the coding problems from following
topics, in round-1 :

Greedy Algorithm
Stack
Queue
Mapping Concepts
Array manipulation
String manipulation
Tree
Dynamic Programming
BackTracking
Graph

ELIGIBILITY FOR TCS CODEVITA 2020

The eligibility criteria of TCS Codevita 2020 are


Coders from institutes across India who are completing their academic course in 2021,2022,2023 and 2024 alone are eligible for
this contest.
Aspirants who are applying for TCS Codevita can apply from any institutes across India.
Graduates, post graduates from Engineering and Science background in any field are eligible for TCS Codevita.
Bride Hunting
Problem Description
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:-
1) The girl should be rich.

2) The girl should be an Engineer/Doctor.


3) The girl should be beautiful.
4) The girl should be of height 5.3".
5) The girl should be working in an MNC.

6) The girl should be an extrovert.


7) The girl should not have spectacles.
8) The girl should be kind and honest.
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
print "“Polygamy not allowed”".
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:
The girl and qualities are present at (1,3),(1,4),(1,6),(1,7),(1,8),(1,9),(2,4),(2,6),(2,9).
The girl present at (1,3) has 2 qualities (i.e. (1,4)and (2,4)).

The girl present at (1,4) has 2 qualities.


The Bride present at (1,6) has 2 qualities.
The Bride present at (1,7) has 3 qualities.
The Bride present at (1,8) has 3 qualities.

The Bride present at (1,9) has 2 qualities.


The Bride present at (2,4) has 2 qualities.
The Bride present at (2,6) has 2 qualities.
The Bride present at (2,9) has 2 qualities.

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 and qualities are present at (3,3),(3,4),(3,5),(4,3),(4,4),(4,5),(5,3),(5,4),(5,5)
The Bride present at (3,3) has 3 qualities (i.e. (3,4),(4,3) and (4,4)).

The Bride present at (3,4) has 5 qualities.


The Bride present at (3,5) has 3 qualities.
The Bride present at (4,3) has 5 qualities.
The Bride present at (4,4) has 8 qualities.

The Bride present at (4,5) has 5 qualities.


The Bride present at (5,3) has 3 qualities.
The Bride present at (5,4) has 5 qualities.
The Bride present at (5,5) has 3 qualities.

As we see, the girl present in (4,4) has maximum number of Qualities. Hence, she is the bride.
Hence, the output will be 4:4:8.

For more Placement Preparation Materials

Join our Community today!

Telegram: @CareerClimbers or
http://t.me/CareerClimbers
Skateboard
Problem Description
The amusement park at Patagonia has introduced a new skateboard competition. The skating surface is a grid of N x N squares. Most
squares are so constructed with slopes that it is possible to direct the skateboard in any of up to three directions of the possible four
(North ,East, South or West, represented by the letters N, E, S and W respectively). Some squares however have a deep drop from
the adjacent square from which it is impossible to go to any adjacent square. These are represented by D (for Drop) in that square.
The objective is to maneuver the skateboard to reach the South East corner of the grid, marked F.
Each contestant is given a map of the grid, which shows where the Drop squares are (marked D), where the Final destination is
(marked F), and, for each other square, the directions it is possible to maneuver the skateboard in that square.
The contestant draws lots to determine which of the squares on the boundaries of the grid on the North or the West of the grid (the
top or the left in the diagram) he or she should start in. Then, using a map of the grid, he or she needs to try to reach the South East
corner destination by maneuvering the skateboard.

.
In some cases, it is impossible to reach the destination. For example, in the diagram above, if one starts at the North East corner (top
right in the diagram), the only way is to go is South, until the Drop square is reached (three squares South), and the contestant is stuck
there.
A contestant asks you to figure out the number of squares at the North or West boundary (top or left boundary in the map) from which
it is feasible to reach the destination.

Constraints
5<=N<=50

Input Format
The first line of the input is a positive integer N, which is the number of squares in each side of the grid.

The next N lines have a N strings of characters representing the contents of the map for that corresponding row. Each string may be
F, representing the Final destination, D, representing a drop square, or a set of up to three of the possible four directions (N,E,S,W)
in some random order. These represent the directions in which the contestant can maneuver the skateboard when in that square.

Output
The output is one line with the number of North or West border squares from which there is a safe way to maneuver the skateboard
to the final destination.

Explanation
Example 1
Input

6
ES,ES,SE,ES,ES,S
SE,ES,SE,ES,ES,S
ES,ES,SE,ES,SE,S

ES,SE,ES,SE,E,D
SE,ES,D,WSE,NES,NS
E,E,NE,E,E,F
Output

9
Explanation
N =6, and the size of the grid is 6x6. The map of the grid is as below.
There are many ways to maneuver the skateboard. For example, if the contestant starts from the North West corner (top left in the
map) and goes East all the way until he reaches the top right corner in the map, and then goes South, he will reach a Drop square. But
if he goes South all the way from the same square until he reaches the bottom left square on the map, and keeps going East from
there, the Final destination will be reached. Hence the top left square (1,1) is safe.
Similarly, from the square (1,5), all the paths lead to a drop square., The other 9 North and West border squares have ways skateboard
to get to the final destination. The output is 9

Example 2
Input
5
ES,SE,ES,SE,S
S,EWS,SE,E,S

E,D,SEW,NSE,S
NE,N,SEW,D,W
EN,EN,E,EN,F
Output
4
Explanation
N=5, and the grid is 5 x 5 squares. The map of the grid looks like this.

It can be seen that from squares (1,4) and (1,5), there is no way to maneuver the skateboard to the Final destination, and hence are
not safe starting points.. Similarly, squares (2,1),(3,1), and (4,1) are not safe starting points. The only safe starting points on the North
and West borders are (1,1),(1,2),(1,3),(5,1). Hence the output is 4
ESESSEESESS
SEESSEESESS
ESESSEESSES

ESSEESSEED
SEESDWSENESNS
EENEEEF
ESSEESSES

SEWSSEES
EDSEWNSES
NENSEWDW
ENENEENF

For more Placement Preparation Materials

Join our Community today!

Telegram: @CareerClimbers or
http://t.me/CareerClimbers
Cross Words
Problem Description
A crossword puzzle is a square grid with black and blank squares, containing clue numbers (according to a set of rules) on some of
the squares. The puzzle is solved by obtaining the solutions to a set of clues corresponding to the clue numbers.
The solved puzzle has one letter in each of the blank square, which represent a sequence of letters (consisting of one or more words
in English or occasionally other languages) running along the rows (called “Across”, or “A”) or along the columns (called “Down”
or “D”). Each numbered square is the beginning of an Across solution or a Down solution. Some of the across and down solutions
will intersect at a blank square, and if the solutions are consistent, both of them will have the same letter at the intersecting square.
In this problem, you will be given the specifications of the grid, and the solutions in some random order. The problem is to number
the grid appropriately, and associate the answers consistently with the clue numbers on the grid, both as Across solutions and as Down
solutions, so that the intersecting blank squares have the same letter in both solutions.

Rules for Clue Numbering


The clue numbers are given sequentially going row wise (Row 1 first, and then row2 and so on)
Only blank squares are given a clue number
A blank square is given a clue number if either of the following conditions exist (only one number is given even if both the conditions
are satisfied)
It has a blank square to its right, and it has no blank square to its left (it has a black square to its left, or it is in the first column). This
is the beginning of an Across solution with that number
It has a blank square below it, and no blank square above it (it has a black square above it or it is in the first row). This is the beginning
of a Down solution with that number

Constraints
5<=N<=15
5<=M<=50

Input Format
The input consists of two parts, the grid part and the solution part
The first line of the grid part consists of a number, N, the size of the grid (the overall grid is N x N) squares. The next N lines
correspond to the N rows of the grid. Each line is comma separated, and has number of pairs of numbers, the first giving the position
(column) of the beginning of a black square block, and the next giving the length of the block. If there are no black squares in a row,
the pair “0,0” will be specified. For example, if a line contains “2,3,7,1,14,2”, columns 2,3,4 (a block of 3 starting with 2), 7 (a block
of 1 starting with 7) and 14,15 (a block of 2 starting with 14) are black in the corresponding row.

The solution part of the input appears after the grid part. The first line of the solution part contains M, the number of solutions. The
M subsequent lines consist of a sequence of letters corresponding to a solution for one of the Across and Down clues. All solutions
will be in upper case (Capital letters)

Output
The output is a set of M comma separated lines. Each line corresponds to a solution, and consists of three parts, the clue number, the
letter A or D (corresponding to Across or Down) and the solution in to that clue (in upper case)
The output must be in increasing clue number order. Ifa clue number has both an Across and a Down solution, they must come in
separate lines, with the Across solution coming before the Down solution.
Explanation
Example 1
Input

5,1

1,1,3,1,5,1

0,0

1,1,3,1,5,1

1,1

EVEN

ACNE

CALVE

PLEAS

EVADE

Output

1,A,ACNE

2,D,CALVE

3,D,EVADE

4,A,PLEAS

5,A,EVEN
Explanation N is 5, and the disposition of the black squares are given in the next 5 (N) lines. The grid looks like this

M=5, and there are 5 (M) solutions.


If the grid is numbered according to the rules, the numbered grid loos like this. Note that row 3 has no blanks, and the input line says
“0,0”

The solutions are fitted to the grid so that they are consistent, and the result is shown below. Note that this is consistent, because the
letter at each intersecting blank square in the Across solution and the Down solution.

Based on this the output is given in clue number order. 1 Across is ACNE, and hence the first line of the output is 1,A,ACNE. The
same logic gives all the remaining solutions.
Example 2

Input

1,1

1,1,3,2

0,0

1,1,3,2

0,0

ASIAN

RISEN

FEAR

CLAWS

FALLS

Output

1,A,FEAR

1,D,FALLS

2,D,RISEN

3,A,CLAWS

4,A,ASIAN

Explanation
N=5, and the grid looks like this
M=5, and the 5 solutions are given
The numbered grid looks like this

The consistently populated grid (with the solutions) look like this

The output can be easily given from this. Note that clue number 1 has both an Across solution (FEAR) and a DOWN solution
(FALLS). The Across solution must precede the Down solution in the output.

For more Placement Preparation Materials

Join our Community today!

Telegram: @CareerClimbers or
http://t.me/CareerClimbers
Bank Compare
Problem Description
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.
Do the computation and make a wise choice.

The loan repayment happens at a monthly frequency and Equated Monthly Installment (EMI) is calculated using the formula given
below :

EMI = loanAmount * monthlyInterestRate /


( 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)
Second line : T – Total Tenure (in years).

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.

The period and rate will be delimited by single white space.

Output
Your decision – either Bank A or Bank B.

Explanation
Example 1
Input
10000
20

3
5 9.5
10 9.6
5 8.5

3
10 6.9
5 8.5
5 7.9

Output
Bank B

Example 2
Input

500000
26
3
13 9.5

3 6.9
10 5.6
3
14 8.5

6 7.4
6 9.6
Output
Bank B

For more Placement Preparation Materials

Join our Community today!

Telegram: @CareerClimbers or http://t.me/CareerClimbers


Jurrasic Park
Problem Description
Smilodon is a ferocious animal which used to live during the Pleistocene epoch (2.5 mya–10,000 years ago). Scientists successfully
created few smilodons in an experimental DNA research. A park is established and those smilodons are kept in a cage for visitors.
This park consists of Grasslands(G), Mountains(M) and Waterbodies(W) and it has three gates (situated in grasslands only). Below
is a sample layout.

Before opening the park, club authority decides to calculate Safety index of the park. The procedure of the calculation is described
below. Please help them to calculate.
Safety Index calculation
Assume a person stands on grassland(x) and a Smilodon escapes from the cage situated on grassland(y). If the person can escape from
any of those three gates before the Smilodon able to catch him, then the grassland(x) is called safe else it is unsafe. A person and a
Smilodon both take 1 second to move from one area to another adjacent area(top, bottom, left or right) but a person can move only
over grasslands though Smilodon can move over grasslands and mountains.
If any grassland is unreachable for Smilodon(maybe it is unreachable for any person also), to increase safe index value Club Authority
use to mark those grasslands as safe land. Explained below

For the above layout, there is only one gate at (4,6)


Y is the position of Smilodon’s cage
X is not safe area
Z is a safe area as is it not possible for smilodon to reach z

Safety index=(total grassland areas which are safe*100)/total grassland area


Constraints
3<= R,C <= 10^3
Gates are situated on grasslands only and at the edge of the park
The cage is also situated in grassland only
The position of the cage and the position of three gates are different

Input Format
The first line of the input contains two space-separated integers R and C, denoting the size of the park (R*C)
The second line contains eight space-separated integers where
First two integers represent the position of the first gate

3rd and 4th integers represent the position of second gate


5th and 6th integers represent the position of third gate respectively
The last two integers represent the position of the cage
Next R lines, each contains space separated C number of characters. These R lines represent the park layout.

Output
Safety Index accurate up to two decimal places using Half-up Rounding method

Explanation
Example 1

Input
44
11213113
GGGG

GWWM
GGWW
MGMM
Output

75.00
Explanation

G G G G

G W WM

G G WW
MG M M

Mountains 4

Gates- Safe Areas 3

Other Safe Areas 3

Waters 4

Cage Pos.-unsafe 1

Other unsafe areas 1

Safety Index= (6*100)/8


Example 2

Input
46
16364634
WMGGGG
MGWGMM
GWGGGG
WGWMWG
Output

69.23

For more Placement Preparation Materials


Join our Community today!
Telegram: @CareerClimbers or
http://t.me/CareerClimbers
String Rotation
Problem Description
Rotate a given String in the specified direction by specified magnitude.
After each rotation make a note of the first character of the rotated String, After all rotation are performed the accumulated first
character as noted previously will form another string, say FIRSTCHARSTRING.

Check If FIRSTCHARSTRING is an Anagram of any substring of the Original string.


If yes print "YES" otherwise "NO". Input
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

Explanation
Example 1
Input
carrace
3
L2
R2
L3

Output
NO

Explanation
After applying all the rotations the FIRSTCHARSTRING string will be "rcr" which is not anagram of any sub string of original
string "carrace".

For more Placement Preparation Materials

Join our Community today!

Telegram: @CareerClimbers or http://t.me/CareerClimbers


Colliding Canons
For more Placement Preparation Materials

Join our Community today!

Telegram: @CareerClimbers or
http://t.me/CareerClimbers
Chakravyuha
Problem Statement
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 hel p
to track of Abhimanyu's advances. Write a program that tracks how many power points Abhimanyu has collected and also
uncover his trail

A Chakravyuha is a wheel-like formation. Pictorially it is depicted as below

A Chakravyuha has a very well-defined co-ordinate system. Each point on the co-ordinate system is manned by a certain unit of
the army. The Commander-In-Chief is always located at the center of the army to better co-ordinate his forces. The only way to
crack the Chakravyuha is to defeat the units in sequential order.

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 la st of the enemy
army unit guards. Remember that he has to proceed by destroying the units in sequential fashion. After destroying the first u nit,
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)

Constraints: 0 < N <=100

Sample Input and Output

SNo. Input Output

12
1 2 43
Total Power points : 1
(0,0)

12345
16 17 18 19 6
15 24 25 20 7
14 23 22 21 8
2 5
13 12 11 10 9
Total Power points : 3
(0,0)
(4,2)
(3,2)

For more Placement Preparation Materials

Join our Community today!

Telegram: @CareerClimbers or
http://t.me/CareerClimbers
Exam Efficiency
In an examination with multiple choice questions, the following is the exam question pattern.

 X1 number of One mark questions, having negative score of -1 for answering wrong
 X2 number of Two mark questions, having negative score of -1 and -2 for one or both options wrong
 X3 number of Three mark questions, having negative score of -1, -2 and -3 for one, two or all three options wrong
 Score Required to Pass the exam : Y
 For 1,2 and 3 mark questions, 1,2 and 3 options must be selected. Simply put, once has to attempt to answer all
questions against all options.

Identify the minimum accuracy rate required for each type of question to crack the exam.
Calculations must be done up to 11 precision and printing up to 2 digit precision with ceil value

Input Format:
First line contains number of one mark questions denoted by X1,
Second line contains number of two mark questions denoted by X2
Third line contains number of three mark questions denoted by X3
Fourth line contains number of marks required to pass the exam denoted by Y.

Output Format:
Minimum Accuracy rate required for one mark question is 80%
Minimum Accuracy rate required for Two mark question is 83.33%
Minimum Accuracy rate required for Three mark question is 90%

Note: - If the mark required to pass the exam can be achieved by attempting without attempting any particular type of question
then show message similar to, One mark question need not be attempted, so no minimum accuracy rate applicable
See Example Test cases for better understanding.

Sample Input and Output


SNo. Input Output Explaination

If one got full marks in two marks


One mark questions need not be attempted, so no minimum question and three marks question
20 accuracy rate applicable. then total accuracy can be 0 in one
1 30 Minimum Accuracy rate required for Two mark question is mark question
30 58.33%
120 Minimum Accuracy rate required for Three mark question is In same way it will be done for
72.23% two marks and three marks
question

If one got full marks in two marks


question and three marks question
then total accuracy should be
20 Minimum Accuracy rate required for one mark question is 100%
100% in one mark question to
2 30 Minimum Accuracy rate required for Two mark question is 100%
pass the exam.
30 Minimum Accuracy rate required for Three mark question is
170 100%
In same way it will be done for
two marks and three marks
question

For more Placement Preparation Materials, Join our Community today!

Telegram: @CareerClimbers or http://t.me/CareerClimbers


Problem : Calculate Salary And PF
Statement :

Calculate the Final Salary & Final Accumulated PF of an Employee working in ABC Company Pvt. Ltd. The Company gives

two Increments (i.e. Financial Year Increment & Anniversary Increment) to an Employee in a Particular Year.

The Employee must have Completed 1 Year to be Eligible for the Financial Year Increment. The Employee who are joining in

the month of Financial Year Change (i.e. April) are considered as the Luckiest Employee's, because after completion of 1 Year,

they get Two Increments

(Financial Year Increment & Anniversary Increment).

Rate of Interest for the Financial Year Increment = 11%.

Rate of Interest for the Anniversary Increment = 12%.

From 4th Year, the Financial Year Increment will be revised to 9%.

From 8th Year, the Financial Year Increment will be revised to 6%.

The Company is giving special Increment for the Employee who have completed 4 years & 8 years respectively.

So, the Anniversary Increment of the Employee for the 4th Year will be 20% and the Anniversary Increment of the Employee for

the 8th year will be 15%.

Calculate the Final Salary after N number of Years as well as Calculate the Accumulated PF of the Employee after N number of

Years.

Please Note that, the Rate of Interest for calculating PF for a Particular Month is 12%. Moreover, take the upper Limit of th e

amount if it is in decimal (For e.g. - If any Amount turns out to be 1250.02, take 1251 for the Calculation.)

Input Format:

1. Joining Date in dd/mm/yy format

2. Current CTC.

3. Number of Years for PF & Salary Calculation.

Output Format:
1. Salary after the Specified Number of Years (i.e. CTC after N number of Years) in the following format

Final Salary =

2. Accumulated PF of the Employee after N number of Years in the following format

Final Accumulated PF =

Constraints:

1. Calculation should be done upto 11 digit precision and output should be printed with ceil value

Sample Input and Output

SNo. Input Output

5
1 01/01/2016 Final Salary = 13924
10000 Final Accumulated PF = 2655
2

19/01/2016
2 Final Salary = 14718
6500
Final Accumulated PF = 4343
4

For more Placement Preparation


Materials
Join our Community today!
Telegram: @CareerClimbers or
http://t.me/CareerClimbers
ISL Schedule
The Indian Soccer League (ISL) is an annual football tournament.

The group stage of ISL features N teams playing against each other with following set of rules:

1. N teams play against each other twice - once at Home and once Away

2. A team can play only one match per day

3. A team cannot play matches on consecutive days

4. A team cannot play more than two back to back Home or Away matches

5. Number of matches in a day has following constraints

o The match pattern that needs to be followed is -

 Day 1 has two matches and Day 2 has one match,

 Day 3 has two matches and Day 4 has one match and so on

o There can never be 3 or more matches in a day

6. Gap between two successive matches of a team cannot exceed floor(N/2) days where floor is the mathematical function

floor()

7. Derby Matches (any one)

o At least half of the derby matches should be on weekend

o At least half of the weekend matches should be derby matches

Your task is to generate a schedule abiding to above rules.

Input Format:

First line contains number of teams (N).

Next line contains state ID of teams, delimited by space

Output Format:

Match format: Ta-vs-Tb


where Ta is the home team with id a and Tb is the away team with id b.

For each day print the match(es) in following format:-

 Two matches:- "#D Ta-vs-Tb Tm-vs-Tn"

 One match:- "#D Tx-vs-Ty"

where D is the day id and [a, b, m, n, x, y] are team ids.

Constraints:

1. 8 <= N <= 100

Note :

 Team ids are unique and have value between 1 to N

 Day id starts with 1

 Every 6th and 7th day are weekends

 Derby is a football match between two teams from the same state

Sample Input and Output

SNo. Input Output

#1 T1-vs-T6 T3-vs-T5
1 8
#2 T7-vs-T4
12543166
#3... and so on

Note:- There can be multiple correct answers for the same test cases.

Explanation:

There are 8 teams with following information:-


Team ID 1 2 3 4 5 6 7 8
State ID 1 2 5 4 3 1 6 6

For more Placement Preparation Materials


Join our Community today!
Telegram: @CareerClimbers or
http://t.me/CareerClimbers
Longest Possible Route
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
Sample Input and Output

SNo. Input Output Explaination

Here matrix will be of size 3x10 matrix with a hurdle at (1,2),(1,5 )


and (1,8) with starting point A(0,0) and stop point B(1,7)

3 10
3 10 3 -- (no. of hurdles )
3 12
12 15
1
15 24 18
18 0 0 -- (position of A)
00 1 7 -- (position of B)
17
So if you examine matrix below shown in Fig 1, total hops

( ->) count is 24. So final answer will be 24. No other route longer
than this one is possible in this matrix.

22
1
2
00 -1 No path is possible in this 2*2 matrix so answer is -1
11
00

For more Placement Preparation Materials


Join our Community today!
Telegram: @CareerClimbers or
http://t.me/CareerClimbers
Sheldon Cooper and his beverage paradigm
Sheldon Cooper, Leonard Hofstadter and Penny decide to go for drinks at Cheese cake factory. Sheldon proposes to make a

game out of this. Sheldon proposes as follows,

 To decide the amount of beverage they plan to consume, say X.

 Then order for a random number of different drinks, say {A, B, C, D, E, F} of quantities {a, b, c, d, e, f} respectively.

 If quantity of any three drinks add up to X then we'll have it else we'll return the order.

E.g. If a + d + f = X then True else False

You are given

1. Number of bottles N corresponding to different beverages and hence their sizes

2. Next N lines, contain a positive integer corresponding to the size of the beverage

3. Last line consists of an integer value, denoted by X above

Your task is to help find out if there can be any combination of three beverage sizes that can sum up to the quantity the y intend

to consume. If such a combination is possible print True else False

Input Format:

1. First line contains number of bottles ordered denoted by N

2. Next N lines, contains a positive integer A i, the size of the ith bottle

3. Last line contains the quantity they intend to consume denoted by X in text above

Output Format:

True, if combination is possible

False, if combination is not possible

Constraints:

N >= 3

Ai > 0
1 <= i <= N

X>0

Sample Input and Output

SNo. Input Output

1 45
True
6

10

22

2 3
False
12

14

Explanation for sample input and output 1:

The sum of 2nd, 5th and 6th beverage size is equal to 22. So the output will be True.
Explanation for sample input and output 2:

Since no combination of given beverage sizes sum up to X i.e. 14, the output will be False.

For more Placement Preparation Materials


Join our Community today!
Telegram: @CareerClimbers or
http://t.me/CareerClimbers
Number Game
Aman and Jasbir are very intelligent guys of their batch. Today they are playing a game "Game of Numbers".

Description of game:

1. There are N numbers placed on a table.

2. Since two players are playing the game, they will make their moves alternatively.

3. In one move a player can perform the following operation.

a. A player will choose a number from the table and will replace that number with one of its divisor. For example,

6 can be replaced with 1, 2, or 3 (since these are the divisors of 6). Similarly, 12 can be replaced with 1, 2, 3, 4

or 6.

b. It is mandatory that the player has to replace the number.

c. A player cannot put back the same number on table.

d. As 1 does not have any divisor other than itself, a player cannot replace 1 with any other number. So soon a

situation will arise when there will be only all 1s on the table. In that situation the player will not be able to

make any move. The player who will not be able to make the move, loses.

4. Both the players are masters of this game. So they will play the game optimally.

5. Aman will make the first move of the game.

You will be given N integers that are on the table. You have to predict, who will win the game - Aman or Jasbir.

Input Format:

First line contains information about the numbers present of the table, denoted by N

Second line contains N integers delimited by space - A1 A2 A3 A4 ......... AN

Output Format:

Print the name of the player who will win the game in upper case i.e. AMAN or JASBIR.

Constraints:
1 <= N <= 100000

0 < Ai <= 10000

A player cannot replace more than 1 number in one move.

Players move alternate and a player cannot pass or make no move.

A number cannot be replaced itself, i.e. 6 can be replaced with 1, 2 or 3 only , not with 6.

Aman always makes the first move.

Sample Input and Output

SNo. Input Output

1 1
AMAN
6

2 2
AMAN
18 6

3 4
JASBIR
24 45 45 24

Explanation for sample input output 1:

There is only one number placed on the table do AMAN will replace it with 1. Jasbir will play next. As there is only 1 left on the

table. And it cannot be replaced with any other number; he is not able to make any move. So he loses the game.

Explanation for sample input output 2:

There are 2 numbers present on the table. Since every move is the optimal move, Aman will replace 18 with 6. Now (6, 6) will

be left on the table. Now, whatever move Jasbir will make. Aman will also make the same move. So whenever Jasbir will

replace any number with 1. In the next move Aman will also replace the other number with 1. So both the numbers will be one

after Aman's move. So Jasbir will lose the game.


Initial configuration - (18, 6)

AFTER Aman's MOVE - (6, 6)

AFTER Jasbir's MOVE - (6, 3)

AFTER Aman's MOVE - (3, 3)

AFTER Jasbir's MOVE - (1, 3)

AFTER Aman's MOVE - (1, 1)

Now, Jasbir WILL NOT BE ABLE TO MAKE ANY MOVE. So, Amanwill WIN.

Explanation for sample input output 3:

In this case, game is already symmetric. Aman has to make the first move. So whatever move Aman will make Jasbir will just

repeat the same. So In the Aman will go out of moves and Jasbir will win the game.

Initial configuration - (24, 45, 45, 24)

AFTER Aman's MOVE - (1, 45, 45, 24)

AFTER Jasbir's MOVE - (1, 45, 45, 1)

AFTER Aman's MOVE - (1, 1, 45, 1)

AFTER Jasbir's MOVE - (1, 1, 1, 1)

Let's see if outcome changes if Aman replaces 24 by 6 instead of 1

Initial configuration - (24, 45, 45, 24)

AFTER Aman's MOVE - (6, 45, 45, 24)

AFTER Jasbir's MOVE - (6, 45, 45, 6)

AFTER Aman's MOVE - (6, 5, 45, 6)

AFTER Jasbir's MOVE - (6, 5, 5, 6)

AFTER Aman's MOVE - (3, 5, 5, 6)

AFTER Jasbir's MOVE - (3, 5, 5, 3)

AFTER Aman's MOVE - (1, 5, 5, 3)

AFTER Jasbir's MOVE - (1, 5, 5, 1)

AFTER Aman's MOVE - (1, 1, 5, 1)

AFTER Jasbir's MOVE - (1, 1, 1, 1)

Now, Aman WILL NOT BE ABLE TO MAKE ANY MOVE. So, Jasbir will WIN. It is easy to see that just by mimicking

Aman's moves, Jasbir will win.


Base Camp

Three friends set out to explore a remote area. They choose a safe place and make it their Base Camp. To speed up exploration

time they decide to work independently. At any given point, either one or more of them can set out to explore the area. They set

a protocol that after exploring the area they must meet back at the Base Camp in the evening and exchange notes.

The remote area consists of accessible and inaccessible pieces of land. Being ordinary humans, they must walk only the

accessible piece of land. In order to maximize their exploration time, each one is interested in knowing about a shortest path

back to the base camp.

Given that the area under exploration is arranged in form of a rectangular grid, help the explorers to chalk out a shortest p ath

back to the base camp. Properties of a rectangle can be used as heuristic in computing distance between their positions and the

Base Camp. Your task is to find out and mark the shortest path for each explorer and print each path as a separate grid.

The input and output specification sections describe how inputs will be provided on console and how output is expected back on

console.

Input Format:

1. First line of input contains grid dimensions delimited by space character

2. Next rows number of lines contain column number of characters

3. Valid characters are {s, d, w, -}, where

a. s represents the location of the explorer

b. d represents the location of the base camp

c. w represents inaccessible region

d. - represents accessible region

4. End of input is marked by -1 character

Output Format:

1. Number of grids in the output should be same as number of explorers i.e. 's' characters in the input grid

2. Each output grid should be of the same dimension as the input grid

3. Each output grid should contain path from explorer location s to base camp location d
4. If there are more than one explorers, explorer with smallest value should be printed first in the output. Next smallest

explorer location should be printed next followed by the last explorer grid.

5. First explorer path should be marked by 'a' character, second by 'b' character and third by 'c' character

6. The 's' character in the grid must be replaced by {a, b or c} whichever is appropriate for the given explorer

7. The 's' character(s) in the grid must be replaced by '-' character for other explorer(s)

8. Output grids must be separated by a blank line

9. See example section for better understanding

Constraints:

1. It is guaranteed that there will always be exactly one shortest path for one explorer from a given location

Sample Input and Output

SNo. Input Output

w-d-

44 waw-

w-d- waww

w-w- a---
1
w-ww w-d-

s--s wbw-

-1 wbww

--bb

a---
44
-a--
s--s
2 --a-
----
---d
----
---b
s--d ---b

-1 ---b

---d

----

----

----

cccd

Explanation for sample input and output 1:

Figure 1.

Figure 2.

Note: - The output format shown above is for understanding purpose such that it highlights the shortest path between the

explorer and the base camp. The examples in above table depicts output in text format as you will be required to provide.

For more Placement Preparation Materials

Join our Community today!

Telegram: @CareerClimbers or
http://t.me/CareerClimbers
Saving for a rainy day
By nature, an average Indian believes in saving money. Some reports suggest that an average Indian manages to save

approximately 30+% of his salary. Dhaniram is one such hard working fellow. With a view of future expenses, Dhaniram

resolves to save a certain amount in order to meet his cash flow demands in the future.

Consider the following example.

Dhaniram wants to buy a TV. He needs to pay Rs 2000/- per month for 12 installments to own the TV. If let's say he gets 4%

interest per annum on his savings bank account, then Dhaniram will need to deposit a certain amount in the bank today, such that

he is able to withdraw Rs 2000/- per month for the next 12 months without requiring any additional deposits throughout.

Your task is to find out how much Dhaniram should deposit today so that he gets assured cash flows for a fixed period in the

future, given the rate of interest at which his money will grow during this period.

Input Format:

First line contains desired cash flow M

Second line contains period in months denoted by T

Third line contains rate per annum R expressed in percentage at which deposited amount will grow

Output Format:

Print total amount of money to be deposited now rounded off to the nearest integer

Constraints:

M>0

T>0

R >= 0

Calculation should be done upto 11-digit precision

Sample Input and Output

SNo. Input Output


500
1 3
1470
12
6000
2 3
17824
5.9
500
3 2
1000
0

For more Placement Preparation Materials


Join our Community today!
Telegram: @CareerClimbers or
http://t.me/CareerClimbers
Catch 22
A robot is programmed to move forward F meters and backwards again, say B meters, in a straight line. The Robot covers 1

meter in T units of time. On Robot's path there is a ditch at a distance FD from initial position in forward direction as well as a

ditch at a distance BD from initial position in backward direction. This forward and backward movement is per formed

repeatedly by the Robot.

Your task is to calculate amount of time taken, before the Robot falls in either ditch, if at all it falls in a ditch.

Input Format:

First line contains total number of test cases, denoted by N

Next N lines, contain a tuple containing 5 values delimited by space

F B T FD BD, where

1. F denotes forward displacement in meters


2. B denotes backward displacement in meters
3. T denotes time taken to cover 1 meter
4. FD denotes distance from Robot's starting position and the ditch in forward direction
5. BD denotes distance from Robot's starting position and the ditch in backward direction

Output Format:

For each test case print time taken by the Robot to fall in the ditch and also state which ditch he falls into. Print F for f orward

and B for backward. Both the outputs must be delimited by whitespace

OR

Print No Ditch if the Robot does not fall in either ditch

Constraints:

1. First move will always be in forward direction


2. 1 <= N <= 100
3. forward displacement > 0
4. backward displacement > 0
5. time > 0
6. distance of ditch in forward direction (FD) > 0
7. distance of ditch in backward direction (BD) > 0
8. All input values must be positive integers only
Sample Input and Output

SNo. Input Output

3
63 F
1 9 4 3 13 10
25 F
9 7 1 11 13
No Ditch
4 4 3 8 12

5
133 F
8 4 7 11 22
216 B
2 4 5 4 25 6
231 B
4 9 3 6 29
408 B
7 10 6 24 12
9F
10 10 1 9 7

For more Placement Preparation Materials


Join our Community today!
Telegram: @CareerClimbers or
http://t.me/CareerClimbers
Credit and Risk Calculator
Money Bank is an investment bank. It gives money to the companies for their operation that approach it. The bank's officers have to
calculate the maximum amount that the company can be given, based on the company's market value and its market rating
published by Global Rating Companies. The maximum amount will change on a daily basis as per the change in the company's
shares, its market value and its change in rating. Based on the maximum amount allocated, the bank internally calculates the
amount that the company can use on a particular day. The maximum amount that the bank will give at any point is 50% of the
company's value, which will decrease as per the change in the company's rating.

Example:

Company ABC has 25734 shares in the market. The current value of the share is 77 INR. The change in the Share Value from
yesterday is +10(or 10) Today's rating of ABC is 87 (out of 100). The change in rating from yesterday is +2 (or 2). The credit and
risk calculator will work in the following way-

Similarly, company XYZ has 30000 shares in the market. The current value of the share is 90 INR. The change in the Share Value
from yesterday is -15. Today's rating of XYZ is 83 (out of 100). The change in rating from yesterday is -4. The credit and risk
calculator will work in the following way-

PCredit
Change in Previous PCompany Previous PMax Credit
No. Of Share Change Allotted (CA)
Share Share Value Value (CV) Company Rating Company is
Shares Value in Rating = CE *
Value (SV') = SV- =N*min Rating (R) (R')= Eligible for (CE)
(N) (SV) ( CR) (min(R',
(CSV) CSV (SV, SV') R-CR =CV * (50%)
R)/100)

=
= (N*67)
(CE*85/100)
= 1724178.00
= 25734 * 67 *0.5
25734 77 10 67.00 87 2 85.00 = 862089 *
0.85
= = 862089.00
1724178.00
= 732775.65

30000 90 -15 105.00 2700000.0 83 -4 87 1350000.00 1120500.00

Input Format:(All black color headings are input in above table)

First line contains total number of test cases T


Each test case comprises of

 First line contains number of shares N


 Second line contains current share value SV
 Third line contains change in share value CSV
 Fourth line contains current rating R
 Fifth line contains change in rating CR

Output Format:(All blue color headings are output in above table)

In case of Valid inputs, print the following per line


Previous Share Value SV'
Previous Rating R'
Company Value CV
Maximum Credit CE
Credit Allotted CA

OR

Print "Invalid Input" in case of invalid input(s)


Constraints:
Highest Priority Constraint

 Share Value (SV and SV') can never be negative

Input related constraints:-

 1 <= T <=100
 20000 <= N <= 10000000
 20.00 <= SV <= 10000.00 (Note:- This is a numerical constraint only)
 -2000.00 <= CSV <= 2000.00 (Note:- This is a numerical constraint only)
 0.01 <= R <= 99.99 (Note:- This is a numerical constraint only)
 -10.00 <= CR <= 10.00 (Note:- This is a numerical constraint only)
 Calculation should be done upto 11-digit precision

The Change in Share Value (CSV) and Change in Rating (CR) are dependent as below:

1. If CSV is Positive, CR can be Positive or Negative.


2. If CSV is Negative, CR cannot be Positive.

Output related constraints:-

The values of CV, CE and CA are to be rounded to 2 Decimal Places, always to the Ceiling or Upper Value
The range of the calculated values are-

 20.00 <= SV' <= 10000.00


 0.01 <= R' <= 99.99
 All output values should be printed upto 2 decimal places.

The output will be invalid in the following cases-

The input ranges or conditions are not satisfied.


The ranges of calculated values are not satisfied.
The relation between CSV and CR is not satisfied
Sample Input and Output

Case # Input Output

4
25000
35
5
85
6
20000
30.00
19
79.00
2
750000.00
60
1 375000.00
3
296250.00
25658
Invalid Input
520
Invalid Input
510
Invalid Input
65
3
22000
30
-5
46
6

For more Placement Preparation Materials


Join our Community today!
Telegram: @CareerClimbers or
http://t.me/CareerClimbers
Reverse Gear
A futuristic company is building an autonomous car. The scientists at the company are training the car to perform Reverse parking.
To park, the car needs to be able to move in backward as well as forward direction. The car is programmed to move backwards B
meters and forwards again, say F meters, in a straight line. The car does this repeatedly until it is able to park or collides with other
objects. The car covers 1 meter in T units of time. There is a wall after distance D from car's initial position in the backward
direction.

The car is currently not without defects and hence often hits the wall. The scientists are devising a strategy to prevent this from
happening. Your task is to help the scientists by providing them with exact information on amount of time available before the car
hits the wall.
Input Format:

First line contains total number of test cases, denoted by N


Next N lines, contain a tuple containing 4 values delimited by space
F B T D, where

1. F denotes forward displacement in meters


2. B denotes backward displacement in meters
3. T denotes time taken to cover 1 meter
4. D denotes distance from Car's starting position and the wall in backward direction

Output Format:

For each test case print time taken by the Car to hit the wall
Constraints:
First move will always be in backward direction
1 <= N <= 100
backward displacement > forward displacement i.e. (B > F)
forward displacement (F) > 0
backward displacement (B) > 0
time (T) > 0
distance (D) > 0
All input values must be positive integers only

Sample Input and Output

SNo. Input Output

2
1 162
6 9 3 18
220
3 7 5 20

For more Placement Preparation


Materials
Join our Community today!
Telegram: @CareerClimbers or
http://t.me/CareerClimbers
Accico Equi Pairs
Ron Wesley has been bit by a three headed snake and Harry Potter is searching for a potion. The Witch promises to tell the
ingredients of the medicine if Harry can find equi pair of an array. Listen to the conversation between Harry The witch to know
more about equi pairs.

Conversation:-

The Witch : To find the equi pair, you must know how to find the slices first.
Harry : What is a slice?
The Witch : If Z is an array with N elements, a slice of indices (X, Y) is Z[X] + Z[X+1]...Z[Y]
Harry : How can I use it to find equi pair?
The Witch : (a, b) is an equi pair if slice of (0, a-1) = slice of (a+1, b-1) = slice of (b+1, N-1) and b>a+1 and size of array > 4
Input Format:

An array of N integers delimited by white space


Output Format:

Print equi pair in first line in the format { a,b }


Print slices in the format { 0,a-1 }, { a+1,b-1 }, { b+1,N-1 }

OR

Print "Array does not contain any equi pair" if there are no equi pairs in the array
Constraints:
Zi >= 0 and 1<= i <=N
size of array (N) > 4
b > (a+1)
Sample Input and Output

SNo. Input Output

Indices which form equi pair { 3,6


1 8 3 5 2 10 6 7 9 5 2 }
Slices are { 0,2 },{ 4,5 },{ 7,9 }

Array does not contain any equi


2 62623319
pair

Explanation for sample input output 1:

Here index { 3,6 } is an equi pair.


Because Slice of { 0,2 } = 8+3+5=16 is equal to Slice of { 4,5 }=10+6 = 16 and it is equal to Slice of { 7,9 }=9+5+2 =16

For more Placement Preparation


Materials
Join our Community today!
Telegram: @CareerClimbers or
http://t.me/CareerClimbers
Drunkard's Walk
In state of inebriation, a drunkard sets out to walk home, afoot. As is common knowledge, a drunkard struggles to find balance and
ends up taking random steps. Not surprisingly these are steps in both forward as well as backward direction. Funnily enough, these
are also repeated movements. Now, it so happens that on this drunkard's path, there are two banana skins - one in forward direction
and one in backward direction. There is a real danger that the drunkard's downfall may be accelerated if he accidentally slips over
either of those banana skins.

Your task is to find out if he will slip over the banana skin on forward path or banana skin on backward path and in how much time.
It is also possible that by his good fortune he might not step over either banana skins. Write a program to calculate the outcome.
Input Format:

First line contains total number of test cases, denoted by N


Next N lines, contain a tuple containing 6 values delimited by space
D FM BM T FBS BBS, where

1. D denotes direction, either F (Forward) or B (Backward)


2. FM denotes the magnitude of forward movement in meters
3. BM denotes the magnitude of backward movement in meters
4. T denotes time taken to cover 1 meter
5. FBS denotes distance from Drunkards' starting position and the banana skin in forward direction
6. BBS denotes distance from Drunkards' starting position and the banana skin in backward direction

Output Format:

For each test case, print time taken by the Drunkard to slip over the forward or backward banana skin. Print F if he slips over
forward banana skin and B if he slips over the backward banana skin. Both the outputs must be delimited by whitespace
OR

Print "Hurray" if the Drunkard is lucky to not slip over either banana skin
Constraints:
1 <= N <= 100
forward movement (FM) > 0
backward movement (BM) > 0
time (T) > 0
Distance to banana skin in forward direction (FBS) > 0
Distance to banana skin in backward direction (BBS) > 0
All input values must be integer only

Sample Input and Output

SNo. Input Output

6
28 B
B 14 12 7 25 4
156 F
B 11 4 6 10 17
1 675 B
F 2 3 9 12 15
102 B
F 1 12 3 22 28
Hurray
B 8 8 5 9 18
35 F
F88579
Earthquake Damage Estimator

Due to the latest earthquake occurrences, the government of "Intelligent Country" is trying to devise a mechanism which can
accurately identify the danger zones based on the origin / epicenter of the earthquake. The mechanism requires that the local map,
the co-ordinates of the epicenter and the intensity (measured in Richter scale) are provided as inputs to the program. The output of
the program would be the map marked with affected areas.

The local map is represented as a grid with square dimensions containing 0's and 1's only. 0's denote the areas which are water
whereas 1 denotes the land areas. Based on the epicenter co-ordinates, all the neighboring inhabited areas that would be affected
needs to be marked as '2'. This process will continue until all the neighboring land areas are processed. Based on the intensity
provided, the areas which would be most affected should be marked as "high risk zones" denoted by '3'. The below table should be
used for reference.
Intensity Impact
<=3.0 All reachable land areas would be marked as affected areas.
>3.0 and <=5.0 The immediate neighbors to the epicenter are the high risk zones.
>5.0 and <=8.0 The first three immediate neighbors would be marked as high risk zones.
>8.0 All reachable land areas would be marked as high risk zones.
Table 1: Intensity-Impact Table

Input Format:

File name, where file contains the information in format described below:

1. First line contains an integer N which denotes the size of the grid
2. Next N lines each contain N elements delimited by space. These elements are only 0's and 1's
3. Next line contains the coordinate of the epicenter. The following applies to the Epicenter
a. It always has to be a land area i.e. it has to be denoted by 1
b. Row and column indexes of the grid start with 1, not 0
c. Coordinates are delimited by space and are of format
4. Last line contains a float value, which denotes intensity of the earthquake in Richter scale

Output Format:

The output or the resulting map (in the form of the square matrix) should be displayed
Sample Input and Output

SNo. Input Output

1022
1 0003
Map1.txt
1030
0033

033020202
000322220
2
Map2.txt 333020022
333302000
030320000
300002222
333320222
002202222
102222002

1033
3 0003
Map3.txt
1003
0033

1022
4 0002
Map4.txt
1002
0022

Explanation:

To understand the input and the output, following content of the file are depicted along with output for better understanding.
File
Contents of file Output Comments
Name
4
1011
Note how epicenter (3, 3) is highlighted in 3rd row and 3rd column.
0001 1022
The intensity of quake is 3.5. Hence according to Intensity-Impact Table we have to
Map1.txt 1 0 1 0 0003
consider immediate neighbours. The immediate land neighbours are [(2,4) (4,3) and
0011 1030
(4,4)]. Per rules, they are set to high risk zone, denoted by 3. The epicenter is also
33 0033
marked as high risk zone.
3.5
033020
202
000322
220
9
333020
011010101
022
000111110
333302
111010011
000 The intensity of quake is 6.95. Hence according to Intensity-Impact Table we have to
111101000
030320 consider three immediate neighbours. Three immediate neighbours is a perimeter of 3
Map2.txt 0 1 0 1 1 0 0 0 0
000 units from the epicenter. In this case the epicenter is (4,1). Hence the perimeter is
100001111
300002 from coordinates (1, 1) to (7, 4).Now applying, the rules we get the depicted output.
111110111
222 Note that the epicenter is also marked as high risk zone.
001101111
333320
101111001
222
41
002202
6.95555930016315
222
102222
002
4
1011
0001 1033
Map3.txt 1 0 0 1 0003 The intensity of quake is 8.95. Hence according to Intensity-Impact Table we have to
0011 1003 consider all reachable land neighbours through which the quake can propagate.
44 0033
8.95
4
1011
0001 1022
The intensity of quake is 1.95. Hence according to Intensity-Impact Table we have to
Map4.txt 1 0 0 1 0002
consider all reachable land neighbours and mark them as affected areas, denoted by 2.
0011 1002
The epicenter is also marked as affected area.
13 0022
1.95

For more Placement Preparation Materials


Join our Community today!
Telegram: @CareerClimbers or
http://t.me/CareerClimbers
Recurring Deposit

Manisha is a smart investor. She has opened a Recurring Deposit (RD) account with a bank. She has negotiated smartly with the
bank. Bank has agreed to vary the interest rate on her RD account such that she is always able to comfortably beat inflation.

Your task is to calculate maturity value of her RD account in face of varying interest rates that she will enjoy.
Input Format:

First line contains principle amount P


Second line contains original rate of interest per annum R
Third line contains tenure in months T
Next few lines contain a tuple with 3 values. Each tuple contains delimited by whitespace, where updated _rate is applied on
From_month and To_month, both inclusive.
-1 shows the end of input
Output Format:

Print the maturity amount after specified tenure or month in the format "Final_Amount "
Constraints:
P > 0 ; it can be float value
R >=0 ; it can be float value
T >0 ; it can be integer only
Calculation should be done upto 11-digit precision
Maturity amount should be printed to its nearest integer value
Sample Input and Output

SNo. Input Output

5000
10
1 12
Final_Amount 63657
3 7 11
8 12 12
-1

2565.50
7.5
2
12 Final_Amount 32097
6 12 8
-1

200.75
3 6.9
Final_Amount 1021
5
-1

For more Placement Preparation


Materials
Join our Community today!
Telegram: @CareerClimbers or
http://t.me/CareerClimbers
Online Communities - Even Groups
In a social network, online communities refer to the group of people with an interest towards the same topic. People connect with
each other in a social network. A connection between Person I and Person J is represented as C I J. When two persons belonging to
different communities connect, the net effect is merger of both communities which I and J belonged to.

We are only interested in finding out the communities with the member count being an even number. Your task is to find out those
communities.

Input Format:

Input will consist of three parts, viz.

1. The total number of people on the social network (N)


2.Queries

 C I J, connect I and J
 Q 0 0, print the number of communities with even member-count

-1 will represent end of input.

Output Format:

For each query Q, output the number of communities with even member-count

Constraints:

1<=N<=10^6

1<=I, J<=N

Sample Input and Output

SNo. Input Output

5
Q00
C12
0
Q00
1 1
C23
0
Q00
1
C45
Q00
-1

Explanation:

For first query there are no members in any of the groups hence answer is 0.
After C 1 2, there is a group (let's take it as G1) with 1 and 2 as members hence total count at this moment is 1.
After C 2 3 total members in G1 will become {1, 2, 3} hence there are no groups with even count.
After C 4 5 there formed a new group G2 with {4, 5} as members, hence the total groups with even count is 1.
Matrix Rotations

You are given a square matrix of dimension N. Let this matrix be called A. Your task is to rotate A in clockwise direction
byS degrees, where S is angle of rotation. On the matrix, there will be 3 types of operations viz.

1. Rotation

Rotate the matrix A by angle S, presented as input in form of A S

2. Querying

Query the element at row K and column L, presented as input in form of Q K L

3. Updation

Update the element at row X and column Y with value Z, presented as input in form of U X Y Z
Print the output of individual operations as depicted in Output Specification

Input Format:

Input will consist of three parts, viz.


1. Size of the matrix (N)
2. The matrix itself (A = N * N)
3. Various operations on the matrix, one operation on each line. (Beginning either with A, Q or U)

-1 will represent end of input.


Note:

 Angle of rotation will always be multiples of 90 degrees only.


 All Update operations happen only on the initial matrix. After update all the previous rotations have to be applied on the
updated matrix

Output Format:

For each Query operation print the element present at K-L location of the matrix in its current state.

Constraints:

1<=N<=1000
1<=Aij<=1000
0<=S<=160000
1<=K, L<=N
1<=Q<=100000

Sample Input and Output

SNo. Input Output


2
12
3
34
1 1
A 90
4
Q11
6
Q12
A 90
Q11
U116
Q22
-1

Explanation:

Initial Matrix

12
34

After 90 degree rotation, the matrix will become


31
42
Now the element at A11 is 3 and A12 is 1.

Again the angle of rotation is 90 degree, now after the rotation the matrix will become
43
21
Now the element at A11 is 4.

As the next operation is Update, update initial matrix i.e.


62
34

After updating, apply all the previous rotations (i.e. 180 = two 90 degree rotations).
The matrix will now become
43
26
Now A22 is 6.

For more Placement Preparation


Materials
Join our Community today!
Telegram: @CareerClimbers or
http://t.me/CareerClimbers
Compiler Design - Limit the Method Instructions
Raj is a newbie to the programming and while learning the programming language he came to know the following rules:
 Each program must start with '{' and end with '}'.
 Each program must contain only one main function. Main function must start with '<' and end with '>'.
 A program may or may not contain user defined function(s). There is no limitation on the number of user defined functions in
the program. User defined function must start with '(' and end with ')'.
 Loops are allowed only inside the functions (this function can be either main function or user defined function(s)). Every loop
must start with '{' and end with '}'.
 User defined function(s) are not allowed to be defined inside main function or other user defined function(s).
 Nested loops are allowed.
 Instructions can be anywhere inside the program.
 Number of instructions inside any user defined function must not be more than 100.

If any of the above conditions is not satisfied, then the program will generate compilation errors. Today Raj has written a few
programs, but he is not sure about the correctness of the programs. Your task is to help him to find out whether his program will
compile without any errors or not.

Input Format:

First line starts with T, number of test cases. Each test case will contain a single line L, where L is a program written by Raj.

Output Format:

Print "No Compilation Errors" if there are no compilation errors, else print "Compilation Errors".

Constraints:

1<=T<=100

L is a text and can be composed of any of the characters {, }, (, ), <, >and P, where P will represents the instruction.

L, comprised of characters mentioned above should be single spaced delimited.


Number of characters in the text, |L| < = 10000

Sample Input and Output

SNo. Input Output

3
No Compilation Errors
1 {<>(P)}
Compilation Errors
{<{}>({}))
Compilation Errors
{({})}

For more Placement Preparation


Materials
Join our Community today!
Telegram: @CareerClimbers or
http://t.me/CareerClimbers
Super ASCII String Checker

In the Byteland country a string "S" is said to super ascii string if and only if count of each character in the string is equal to its ascii
value.

In the Byteland country ascii code of 'a' is 1, 'b' is 2 ...'z' is 26.

Your task is to find out whether the given string is a super ascii string or not.

Input Format:

First line contains number of test cases T, followed by T lines, each containing a string "S".

Output Format:

For each test case print "Yes" if the String "S" is super ascii, else print "No"
Constraints:

1<=T<=100
1<=|S|<=400, S will contains only lower case alphabets ('a'-'z').

Sample Input and Output

SNo. Input Output

2
1 Yes
bba
No
scca

Explanation:

In case 1, viz. String "bba" -


The count of character 'b' is 2. Ascii value of 'b' is also 2.
The count of character 'a' is 1. Ascii value of 'a' is also 1.
Hence string "bba" is super ascii.

For more Placement Preparation


Materials
Join our Community today!
Telegram: @CareerClimbers or
http://t.me/CareerClimbers
Zombie World
Zoya has developed a new game called Zombie World. The objective of the game is to kill all zombies in given amount of time.
More formally,

 N represents the total number of zombies in the current level


 T represents the maximum time allowed for the current level
 P represents the initial energy level a player starts with
 Ei defines the energy of the i-th zombie
 D defines the minimum energy the player needs, to advance to the next level
When a player energy is greater than or equal to the i-th zombie's energy, the player wins. Upon winning, the player will be
awarded with an additional energy equal to the difference between current zombie energy and the player energy.
One unit of time will be taken to complete the fight with a single zombie.
Rules of the game:-
 At any given time, a player can fight with only one zombie
 Player is allowed to choose any one zombie to fight with.
Your task is to determine whether the player will advance to the next level or not, if he plays optimally.

Input Format:

The first line contains the number of test cases (K)

Each test case consists of three parts:

1. The total number of zombies (N) and the maximum time allowed (T)
2. Array of size N, which represents the energy of zombies (E)
3. The initial energy level a player (P) and the minimum energy required to advance (D)

Output Format:

Print "Yes" if a player can advance to the next level else print "No".

Constraints:

1<=K<=10
1<=N<=50
1<=Ei<=500
1<=T<=100
1<=D<=2000
1<=P<=500

Sample Input and Output

SNo. Input Output

1
1 23
Yes
45
57

For more Placement Preparation Materials


Join our Community today!
Telegram: @CareerClimbers or
http://t.me/CareerClimbers
Stone Game - One Four

Alice and Bob are playing a game called "Stone Game". Stone game is a two-player game. Let N be the total number of stones. In
each turn, a player can remove either one stone or four stones. The player who picks the last stone, wins. They follow the "Ladies
First" norm. Hence Alice is always the one to make the first move. Your task is to find out whether Alice can win, if both play the
game optimally.

Input Format:

First line starts with T, which is the number of test cases. Each test case will contain N number of stones.

Output Format:

Print "Yes" in the case Alice wins, else print "No".

Constraints:

1<=T<=1000
1<=N<=10000

Sample Input and Output

SNo. Input Output

3
Yes
1 1
Yes
6
No
7

For more Placement Preparation


Materials
Join our Community today!
Telegram: @CareerClimbers or
http://t.me/CareerClimbers
Trace the Rats
Given a square maze (A) of dimension N, every entry (Aij) in the maze is either an open cell 'O' or a wall 'X'. A rat can travel to its
adjacent locations (left, right, top and bottom), but to reach a cell, it must be open. Given the locations of Rrats, can you find out
whether all the rats can reach others or not?

Input Format:

Input will consist of three parts, viz.

1. Size of the maze (N)


2. The maze itself (A = N * N)
3. Number of rats (R)
4. Location of R rats (Xi, Yi)

Note:

 (Xi,Yi) will represents the location of the i-th rat.


 Locations are 1-index based.

Output Format:

Print "Yes" if the rats can reach each other, else print "No"

Constraints:

1<=N<=350
Aij = {'O','X'}
1<=R<=N*N
1<=Xi<=N
1<=Yi<=N

Sample Input and Output

SNo. Input Output

3
OOX
OXO
OOX
1
4 Yes
11
12
21
32

3
OOX
OXO
OOX
2
4 No
11
12
21
23
On A Cube
A solid cube of 10 cm x 10cm x 10 cm rests on the ground. It has a beetle on it, and some sweet honey spots at various locations on
the surface of the cube. The beetle starts at a point on the surface of the cube and goes to the honey spots in order along the surface
of the cube.

If it goes from a point to another point on the same face (say X to Y), it goes in an arc of a circle that subtends an angle of 60
degrees at the center of the circle
If it goes from one point to another on a different face, it goes by the shortest path on the surface of the cube, except that it never
travels along the bottom of the cube

The beetle is a student of cartesian geometry and knows the coordinates (x, y, z) of all the points it needs to go to. The origin of
coordinates it uses is one corner of the cube on the ground, and the z-axis points up.Hence, the bottom surface (on which it does not
crawl) is z=0, and the top surface is z=10.The beetle keeps track of all the distances traveled, and rounds the distance traveled to
two decimal places once it reaches the next spot so that the final distance is a sum of the rounded distances from spot to spot.

Input Format: The first line gives an integer N, the total number of points (including the starting point) the beetle visits

The second line is a set of 3N comma separated non-negative numbers, with up to two decimal places each. These are to be
interpreted in groups of three as the x, y, z coordinates of the points the beetle needs to visit in the given order.

Output Format: One line with a number giving the total distance traveled by the beetle accurate to two decimal places. Even if the
distance traveled is an integer, the output should have two decimal places.

Constraints: None of the points the beetle visits is on the bottom face (z=0) or on any of the edges of the cube (the lines where two
faces meet)

2<=N<=10
Sample Input-Output:

Input
3
1,1,10,2,1,10,0,5,9
Output
6.05
Input
3
1,1,10,2,1,10,0,1,9
Output
4.05

For more Placement Preparation


Materials
Join our Community today!
Telegram: @CareerClimbers or
http://t.me/CareerClimbers
Angels vs Devils
In a board game (12x12) of Angels vs Devils, various devils try to kill an angel whose aim is to get across the board. Person playing
for devil can place 3 devils at any cell on the board, each devil has different powers.

Starting point of Angel can only be on border but not corners of the board and will be provided as input. He will walk in a straight
line (horizontal or vertical only) across the board, one cell every second. For example, if he is placed on the left border he will
move right towards the right border. Starting points and types of devils will be provided as input, their powers are as follows
(please also refer the image in Example 1).

OGRE (O): He cannot move but he can kill with his breath. His powers change with time.
· In 1st second Ogre can kill angel if the angel reaches Ogre’s location
· In 2nd second Ogre can kill angel surrounding upto 8 neighbouring cells (see diagram)
· In 3rd second Ogre can kill angel if the angel reaches Ogre’s location
· In 4th second Ogre is powerless i.e. even if angel reaches Ogre’s location, Ogre cannot harm him

XiXi (X): He has the power to kill an angel only if both the following conditions are true

· He is active
· Angel is on same colored cell as XiXi

XiXi is active only for 1 particular second in this game. According to Figure 1, XiXi is on cell D8. What this means is – XiXi
will be active only in 8th second and if and only if angel is on blue colored square at 8th second, XiXi can kill the angel.
ZeeSNAKE (Z): He leaves a poison trail and moves in 'Z' shape. His first move is 'down' and then 'right' and keeps on making a
trail in that order until he reaches the border. If he reaches the 'Bottom Border' he starts moving 'up' instead of 'down' and vice-
versa. If he reaches the 'Right Border' he starts moving 'left' instead of 'right' and vice-versa. Angel coming on the poison box will
die immediately. Trail created by him till 12th second is shown in Figure 1
You need to provide the box number on which the Angel gets killed, or output 'SS' if Angel successfully crosses the board
Constraints

Angel starts from the border but not from the corners (i.e. cells A1, A12, L1 and L12)

Starting points of angel and all the devils will be different

Powers of devils do not conflict. Thus if an angel reaches a cell which is under influence of more than one devil’s power, the
angel will still get killed

Angel cannot stop, he has to move every second

Input Format

First Line contains the starting point of Angel at t = 1.


Second Line contains the types of devils in order delimited by comma (,).
Third Line contains starting points of devils (at t = 1) in order delimited by comma (,).
Output

Cell number where the angel gets killed, if angel does not get killed then print "SS"
Test Case
Explanation
Example 1

Input

K12
O,X,Z

I3,D8,C4

Output

K5

Explanation

Angel will be killed by the Devil XiXi as at the 8th second, he can kill angel on blue boxes

Figure. 1.

Example 2

Input

I12

Z,O,X

K2,B10,G3

Output

SS

Explanation

Angel is successfully saved because no devil’s power is able to harm him.


Figure. 2.

For more Placement Preparation


Materials
Join our Community today!
Telegram: @CareerClimbers or
http://t.me/CareerClimbers
King Placement
This is a typical chess game where your opponent first places random number of Knights, Rooks, Bishop and Queens on an
N*N chess board and then you have to place your king safely on chess board
such that it should not be under attack by any piece.

Note: if you don't know how to play chess and how chess pieces moves, please refer below link (you can concentrate only on how
the above mentioned pieces moves).

https://www.instructables.com/id/Playing-Chess/

Given an N*N chessboard with K number of Knights, R number of Rooks, B number of Bishops and Q number of queens. Your
task is to find out number of squares on the chess board such that your King is not checked by any of your opponents pieces.
Constraints
2<=N<=50

0<=K+R+B+Q <=N*N

0<=i, j <=N-1

Input Format
First line provides an integer N

Next line contains K, no. of Knights. Next K lines provide 2 space separated integers denoting the rank and the file of the Knights
(i,j)

Next line contains R, no. of Rooks. Next R lines provide 2 space separated integers denoting the rank and the file of the Rooks
(i,j)

Next line contains B, no. of Bishops. Next B lines provide 2 space separated integers denoting the rank and the file of the Bishops
(i,j)

Next line contains Q, no. of Queens. Next Q lines provide 2 space separated integers denoting the rank and the file of the Queens
(i,j)

Output
Number of squares where King can be placed safely.

Test Case Explanation


Example 1 Input
4

00

11

22

33
Output 2
Explanation

The image shows the arrangement of the pieces. After the placement of all the Pieces as per
the input chess board looks like the image above,

You can place king in 2 places safely, i.e. (0,1) and (1,0)

Example 2
Input

8
4
26
32
56
77
4
22
46
64
75
4
04
11
16
51
2
35
60

output 5
Explanation

For more Placement Preparation Materials

Join our Community today!

Telegram: @CareerClimbers or http://t.me/CareerClimbers


Glass Piece
Problem Description

A square glass sheet of size 'S' cm fell down and broken down into N+1 pieces.

A man collected the broken pieces and he is trying to arrange the pieces to get the original shape. He found that exactly one piece
is missing. To find the exact position of the missing piece, he noted down all (x,y) coordinates of each broken piece. Please help
him to find the coordinates of the missing piece.

Note 1 : The input order of corners of known glass pieces are in the clockwise direction starting from the corner having least X
value. If more than one corners having the same least X value, then start from the corner having least X and least Y value.

Note 2 : The corners of missing glass piece should output in the clockwise direction starting from the corner having least X value.
If more than one corners have same least X value, then start from the corner having least X and least Y value.

Constraints

1 < S <= 1000.

1 < N <= 50.

Input Format

First line contains an integer, S, size of Glass Sheet.

Second line contains an integer, N.

Next N lines contain set of space separated integers indicates the details of N known glass pieces as follows:

· First number indicates total corners of that glass piece - say i,

· followed by 2 * i integers denotes X and Y coordinates of i corners, delimited by space

Output

Coordinates of missing piece in (X,Y) format separated by spaces.

Test Case
Explanation
Example 1

Input

400

5 0 0 200 0 400 200 100 250 0 250

3 200 0 400 0 400 200

4 100 250 400 200 400 400 200 400

Output
(0,250) (100,250) (200,400) (0,400)

Explanation

The size of the square glass plate is 400 cm * 400 cm. The glass plate broke into 4 pieces and he got 3 pieces.

He placed first glass piece as below figure:

Figure. 1

Next he placed second glass piece as below figure:

Figure. 2

Next he placed third glass piece as below figure:


Figure. 3

Finally he found the position of the missing piece as below figure:

Figure. 4

Lastly, display the coordinates of missing glass piece in the clockwise direction starting from the corner (0,250), as output

For more Placement Preparation Materials


Join our Community today!
Telegram: @CareerClimbers or
http://t.me/CareerClimbers
Clock Angle
Problem Description

There are 360 Longitudes on the Earth, which are equidistant vertical imaginary lines drawn on the Earth,
separated by 1 degree each from center of the Earth. Period of the rotation of the Earth on its axis is 24 hours. All
countries have their own official times and hence time zones.

UTC is universal time coordinate which passes through 0 (Zero degree) longitude.

Time at a particular location on Earth can be calculated using period of the rotation of Earth and longitude of that
particular location. For example, Indian time zone IST (Indian standard Time) is located at 82.5° E longitude.
Hence, Indian time can be calculated as below:-

IST = UTC + (24/360)*82.5 = UTC + 5:30Hrs

Now suppose we changed period of rotation of the earth using some imaginary power, this will change the time
at every longitude on the earth.

Calculate the smallest angle between hour and minute hand of the clock , which shows the difference of time at a
particular longitude and the time at UTC i.e. we have to take smaller of the two angle formed between hour and
minute hand.

Constraints

To show the time difference on clock, 12-hour clock (as shown below) shall be used, irrespective of period of the
earth's rotation, for this question only.

Input Format

1. Period of the earth’s rotation in Hours (Integer only)

2. Value of Longitude up to 2 place of decimal

Output
Smallest angle between hour and minute hand of the clock, which shows the difference between time at a
particular longitude and time at UTC, up to 2 decimal places.
Test Case

Explanation

Example 1

Input

24

82.50

Output

15.00

Explanation

If period of rotation of earth is 24 hours then time at 82.5 degree longitude will be (24/360)*82.50 = 5:30 and
minimum angle at this time between minute and hour hand will be 15 degree.

Example 2

Input

12

360.00

Output 0.00

Explanation

If period of rotation of earth is 12 hours then time at 360 degree longitude will be (12/360)*360 = 12:00 and
minimum angle at this time between minute and hour hand will be 0 degree.

For more Placement Preparation


Materials
Join our Community today!
Telegram: @CareerClimbers or
http://t.me/CareerClimbers
Salary Paid
Problem Description

In a country, there are 'N' slabs for Income tax which are common for all age groups and genders. As an income
tax officer, investigating a case, you have the amount of tax paid by each employee of an organization. Considering
the income tax slabs and rebates offered, you need to find the total amount paid by the organization in salaries to
the employees to match it with the amount reported by the organization in its filed Income tax Returns. Information
regarding the income tax slabs, rebate amount and the income tax paid by each employee of the organization will
be provided. Rebate amount is subtracted from the total salary of each employee. Tax is calculated on the
remaining amount. You need to calculate the sum of total salary paid to the employees in that year.

Constraints

Number of tax slabs = Number of percentage on tax slabs 0<=

Rebate, tax paid, slab <=1000000

Input Format

First Line will provide the Amount in each slab, separate by space (' ')

Second Line will provide the percentage of tax applied on each slab. Number of values in this line will be same
as that in line one, separate by space (' ')

Third Line will provide the Rebate considered

Fourth line will provide the tax paid by each employee, separate by space (' ')

Output

Total Salary paid by the organization to its employees


Test Case Explanation
Example 1

Input

300000 600000 900000


10 20 30
100000
90000 150000 210000 300000

Output
5300000

Explanation
Slabs and tax percentage indicate that for salary:
Between 0 - 300000, tax is 0%
Between 300001 - 600000, tax is 10%
Between 600001 - 900000, tax is 20%
Greater than 900001, tax is 30%

First, we exclude the rebate from the salary of each employee. This will be the taxable component of salary. Upon,
taxable salary apply the slab and tax percentage logic. Upon computation, one finds that employees are paid
amounts 1000000, 1200000, 1400000, 1700000 respectively, as salaries. So, the total salary paid to all employees
in that year will be 5300000.
Hint: - It may be helpful to browse the internet to know general rules regarding income tax calculations.
Marathon Winner
Problem Description

Race is generally organized by distance but this race will be organized by time. In

order to predict the winner we will check every 2 seconds.

Let’s say total race time is 7 seconds we will check for (7-1) seconds. For

7 sec : We will check who is leading at 2 sec, 4 sec and 6 sec.

Participant who is leading more number of times is winner from prediction perspective. Now

our task is to predict a winner in this marathon.

Note:

1) At particular time let say at 4th second, top two (top N, in general) participants are at same distance, then
in this case both are leading we will increase count for both (all N).

2) And after calculating at all time slices, if number of times someone is leading, is same for two or more
participants, then one who come first in input sequence will be the winner.

Ex: If participant 2 and 3 are both leading with same number, participant 2 will be the winner.

Constraints

1 <= T <= 100

1 <= N <= 100

Input Format

First line contains a single integer N denoting the number of participants

Second line contains a single integer T denoting the total time in seconds of this Marathon. Next

N lines (for each participant) are as follows :

We have T+1 integers separated by space. First

T integers are as follow:

ith integer denotes the number of steps taken by the participant at the ith second.

T+1st integer denotes the Distance (in meters) of each step.

Output

Index of Marathon winner, where index starts with 1.

Test Case Explanation

Example 1

Input

3
8

224352623

357439322

124275324

Output 2

Explanation

3 (No. of candidate)

8 (Total time of Sprint (In seconds))

2 2 4 3 5 2 6 2 3 ( data for 1st candidate. First 8 integers denote number of steps per second and last integer
denotes distance covered in each step i.e. 3).

3 5 7 4 3 9 3 2 2 (similarly, 2nd candidate’s data).

1 2 4 2 7 5 3 2 4 (similarly, 3rd candidate’s data). At

time 2: Here 2nd marathoner is leading

12 (2*3+2*3)

16 (3*2+5*2)

12 (1*4+2*4)

At time 4 :Here also 2nd marathoner is leading 33 (

2*3+2*3 +4*3+3*3)

38

36

At time 6 :Here 3rd marathoner is leading 57

62

84

Output: 2

Since, 2nd marathoner is leading more number of times, so 2 is the winner.

For more Placement Preparation Materials


Join our Community today!
Telegram: @CareerClimbers or
http://t.me/CareerClimbers
Lazy Student
Problem Description
There is a test of Algorithms. Teacher provides a question bank consisting of N questions and guarantees all
the questions in the test will be from this question bank. Due to lack of time and his laziness, Codu could
only practice M questions. There are T questions in a question paper selected randomly. Passing criteria is
solving at least 1 of the T problems. Codu can't solve the question he didn't practice. What is the probability
that Codu will pass the test?
Constraints

0 < T <= 10000

0 < N, T <= 1000

0 <= M <= 1000

M,T <= N

Input Format

First line contains single integer T denoting the number of test cases.

First line of each test case contains 3 integers separated by space denoting N, T, and M.

Output

For each test case, print a single integer.

If probability is p/q where p & q are co-prime, print (p*mulInv(q)) modulo 1000000007, where mulInv(x) is
multiplicative inverse of x under modulo 1000000007.

Test Case
Explanation
Example 1

Input

421

Output

500000004

Explanation

The probability is ½. So output is 500000004.

For more Placement Preparation Materials


Join our Community today!
Telegram: @CareerClimbers or
http://t.me/CareerClimbers
Friend Circle
Problem Description
2N friends (A,B,C... , 2N) are standing in a circle. There is exactly one person standing opposite of one other
person. Some of them are facing inwards and some of them are facing outwards. Here given some facts your
task is to build the standing positions and answer a few Questions. If the arrangement is not possible or more
than one arrangement is possible, then print "ARRANGEMENT NOT POSSIBLE".

The formats of Facts & Questions and its meanings are as follows.

Facts
"1AB" means : A and B are standing adjacent to each other
"2AB" means : A and B are standing opposite to each other
"3AB" means : A is standing to the immediate left of B
"4AB" means : A is standing to the immediate right of B
"5A" means : A is facing inwards
"6A" means : A is facing outwards
"7n" means : n people are facing inwards, where n is a number
"8n" means : n people are facing outwards, where n is a number
Questions
"?2A" means : who is standing opposite of A?
'?3A" means : who is standing to the immediate left of A?
"?4A" means : who is standing to the immediate right of A?
"?5A" means : is A facing inwards? Ans:Y/N
"?6A" means : is A facing outwards? Ans:Y/N
Constraints
1 < N < 10

1 < Total Facts < 30

1 < Total Questions < 20

Input Format
N Multiple facts, separated by semicolon multiple questions, separated by semicolon

Output
Answers, separated by semicolon corresponding to order of questions OR "ARRANGEMENT NOT
POSSIBLE"

Test Case

Explanation
Example 1

Input

2
2AB;72;1AC;6D;4BD;6C
?2D;?3C;?4B;?5A;?6B

Output
C;B;D;Y;N

Explanation

4 people- A, B, C and D are standing in circle.


There are 6 facts separated in semicolons:
2AB ==> A and B are standing opposite
72 ==> 2 people are facing inwards
1AC ==> A and C are standing nearby
6D ==> D is facing outwards
4BD ==> B is standing immediate right of D
6C ==> C is facing outwards
From the above facts, we can build the standing positions as below image:

There are 5 questions:


?2D ==> who is standing opposite of D? Ans:C
?3C ==> who is standing immediate left of C? Ans:B
?4B ==> who is standing immediate right of B? Ans:D
?5A ==> is A facing inwards? Ans:Y
?6B ==> is B facing outwards? Ans:N
Finally printing all answers in a single line separated by semicolon.

Example 2

Input

2
4BA;3CA;3CD;5C;5B
?5A;?3D;?4C;?6B

Output

ARRANGEMENT NOT POSSIBLE

Explanation

We can arrange 4 people in two different ways as the image below, from the facts provided. Directions of A
and D can be set differently.
For more Placement Preparation
Materials
Join our Community today!
Telegram: @CareerClimbers or
http://t.me/CareerClimbers

You might also like