CodeVita 2014 Round 2 PDF
CodeVita 2014 Round 2 PDF
Input Format:
First line contains the text. Next line contains K, lb, ub. Next K lines consist of alpha
words in the text.
Note:
1. String comparison should be case insensitive.
2. String comparison should be based only on words comprised of alphabets. Non -
alphabet characters such as Full Stop ("."), Exclamation Marks ("!") etc. are called as
Stop words. Stop words must be removed from sentences before comparison.
3. If more than one segment starts with the same index (i.e. position of the word in the
text), then consider the shortest segment. In other words, segments should begin from
unique indexes.
Output Format:
Print the number of valid segments with number of beta words in the given range [lb,
ub].
Constraints:
1<= total number of words in the text <= 30,000
1<= length of alpha and beta words <= 500
1<=K<=total number of alpha words
1<=lb<=ub<=total number of beta words
Sample Input and Output
There is only one valid segment with number of beta words in the range [3, 4], which is
segment 2.
A is the square matrix of size N. Every entry in the matrix will contain a lower case
alphabet. Given Z strings, for each string your task is to find out the closest square-
matrix starting from (1, 1). Closeness between the sub-matrix and the string is defined
as, number of similar characters between the two. The input is guaranteed to have at
least one character that is same in string Zi and matrix A, where Zi is the ith string. The
same cell in the sub-matrix of A cannot be counted more than once to match with the
character in the S.
Input Format:
First line of input will consist of T Test cases. Each test case will consist of four parts, viz.
1. Size of the matrix (N)
2. The matrix itself (A = N * N) where elements are delimited by space.
3. Number of Strings (Z)
4. Z lines each comprising of string S
Output Format:
For every string print the bottom right co-ordinates of the square-matrix closest from (1,
1).
Constraints:
1<=T<=5
1<=N<=500
'a'<=Aij<='z', where Aij is the entry of the matrix at ith row and jth column(1-index
based).
1<=Z<=25000
1<=|S|<=500
1
1 33
4 33
aerd 44
plxl
lpxz
cqxo
3
apple
alex
aero
Explanation:
String S: "apple"
Sub matrix: (1, 1) to (3, 3)
aer
plx
lpx
Sub matrix contains all characters of string S, hence the output
Given a list of unique employee ids and their age information, your task is to design a
program to support the certain operations. Broadly speaking there are two operations,
Insert and Query. You can assume that insert operations are unique on the employee _id
column. Query operations are of 3 types. Both insert and query operations are described
below.
1. A {employee_id} {age}
Operation will add the employee_id and age.
Syntax: A {employee_id} {age}
Returns: None
2. Q 1 {employee_id}
Query will search for the records whose employee id is {user_employee_id}.
Syntax: Q 1 {employee_id}
Returns: Boolean (True or False)
3. Q 2 {employee_id}
Query will search for the records whose employee id starts with {user_employee_id}.
Syntax: Q 2 {employee_id}
Returns: Total count of the records which matches the search criteria.
Input Format:
Every input line consists of either Add (A) or Query (Q) operation. -1 represents the end
of input.
Output Format:
Constraints:
1 <= Total digits in the Employee ID <= 50
20 <= Age <= 100
10 <=lb<= 100, where lb is a multiple of 10.
lb <=ub<= 100, where ub is a multiple of 10.
Total number of add operations <= 40000
Total number of query operations <= 40000
A 112345 20
A 112346 40
A 212347 40
A 212348 23
A 112449 30
Q 1 112345
Q 2 1123 True
Q 3 112 10 50 2
1 -1 3
NOTE:
Minimum time required for evaluating this program is 24 seconds. Please be patient.
Request you to wait up to a few minutes before resubmitting the same solution.
Adam is working in a large hierarchical organization, where every employee, except the
CEO, is either a supervisor or a sub-ordinate or both. Every employee will be identified
by Employee ID. CEO of the company has 1 as his employee id. Every employee will get
the salary (S) in accordance with their level and their performance. Given the data about
the all the above mentioned details, your task is to find out the number of sub-ordinates
with salary less than Adam.
Note:
1. If an employee appears at two different levels, then consider the level which is near
(best) to the CEO.
2. An employee is considered as sub-ordinate, if Adam is a direct or indirect supervisor
to the said employee.
Input Format:
Output Format:
Print the total number of employees who are sub-ordinates to Adam and have salary less
than Adam's.
Constraints:
1<=N<=50
1<=M<=1000
1<=I, J<=N
1<=S<=50000
K friends came to the city and they are in search of some nice flats to stay. At most they
can spend T Rupees for the accommodation. Finally they came to know about Marika
Apartments, where there exist N empty flats, and every flat owner is allowing at -most Pj
persons to stay in a jth flat. So finally they have decided to stay in the multiple flats, at
the same time they would like to stay in such flats in which every person from the K
person group should able to reach the other K-1 friends who are actually staying either
in the same flat or in the other flat.
Let Rj define the rent of the jth flat. One of the major problem in the apartment is only
few flats are reachable from the other and one can take the advantage of one flat to
reach the other in an indirect way. Now having all the above information your task is to
help K friends to know how many options are available for them to stay.
Input Format:
Output Format:
Print the number of options i.e. number of different ways in which K friends can have
their space and stay connected too.
Constraints:
1<=K<=100
1<=N<=500
1<=T<=10 ^ 6
1<=Rj<=5000
1<=Pj<=100
5 4 10000
0011
1000
0100
0001
5432
1 2000 1500 1500 2500 1
13 4 10000
0011
1000
0100
0001
5432
2 2000 1500 1500 2500 0
A string is said to be palindrome, if it reads the same from both the ends. Given a string
S, you are allowed to perform cyclic shifts. More formally, you can pick any one
character from any end (head or tail) and you can append that character at the other
end. For example, if the string is "abc", then if we do a shift using the character at head
position then the string becomes "bca". Similarly, if we do the shift using the character
at the tail then the input string becomes "cab". Your task is to find out the minimum
number of shifts needed to make the given string, a palindrome. In case, we can't
convert the string to palindrome then print -1.
Input Format:
First line starts with T i.e. number of test cases, and then T lines will follow each
containing a string "S".
Output Format:
Print the minimum number of cyclic shifts for each string if it can be made a palindrome,
else -1.
Constraints:
1<=T<=100
1<=|S|<=300, S will contains only lower case alphabets ('a'-'z').
4
abbb -1
aaabb 1
aabb 1
1 abc -1
Explanation:
Please do not use package and namespace in your code. For object oriented languages
your code should be written in one class.
Participants submitting solutions in C language should not use functions from / as these
files do not exist in gcc