CodeNation CNIL Recruitment test 2020
CodeNation CNIL Recruitment test 2020
About Codenation
- CodeNation is a software solutions company that is Indian daughter branch of the company DevFactory, which in turn is the research and development wing of the Trilogy Group. More on Trilogy group here- Trilogy (company).
- The main goal of the company is to optimise the software development process and deliver cost-effective world-class software products
- Trilogy group as a company owns many software development firms itself.
Recruitment Process:
- Coding Round
- Technical Round 1
- Technical Round 2
- Technical Round 3
- HR Round
Coding Round:
The Codenation hosts its coding round on Hackerrank and generally goes by
the name of CodeAgon.
In 2020 it is conducted by the name 'CNIL 2020'. The round
consists of about 3 questions ranging from the lower to higher difficulty.
The questions are generally from the following paradigms-
- AdHoc (Brute Force)
- Combinatorics
- Dynamic programming
- Segment tree etc.
Duration : 1 hours 30 minutes.
Generally conducted in between July last week - August first
week.
Mode of Recruitment : OFF CAMPUS
Package for full time employee: INR 31 lakhs per annum (26 lakhs
fixed)
Package for summer interns : INR 75,000 per month for 2 months
CNIL 2020 Questions:
1. String Reduction
Your task is to return the largest string, based on dictionary order,
that can be obtained by erasing a certain number characters from
that sting.
For two strings x and y, each consisting of m characters, x is larger
than y, based on dictionary order, when the first j-1 letters in x
and y are equal Where 1 <= j<= m, but the jth letter in x is
larger than the jth letter in y.
For example, "caa" is larger than "baa". and "abza" is larger
than "abqa".
Consider the following example.
Let the string. s, be 'baca' the number of characters to be erased, k.
is 1 .There are 4 possible ways of deleting exactly ore character from
that string "aca","bca", "baa" and 'bac". Among these strings, "bca" is
the largest in dictionary order. Thus, "bca" is the desired
answer.
Function Description
compete the function StringReduction in the editor below. The function
must return the largest string, based on dictionary Order, that can be
obtained by erasing exactly k characters from the input
sting.
"StringReduction" has the following parameters:
- k: an integer
- s: an String of length n
Constraints
• 1<= n <=10^6
• 0<=k<=n
• s contains only English lowercase letters.
Input Format For Custom Testing
The first line contains a single integer, k, denoting the number of
characters to erase. In the second line, there is a single string, s,
denoting the string to erase the characters from.
Sample Case 0
Sample Input for Custom Testing
1
zyxedcba
Sample Output
zyxedcb
Explanation
The input string, s, is "zyxedcba", and the number of charaters to
erase k is 1.
The possible ways of erasing exactly 1 character are:
"yxedcba"
"zxedcba"
"zyedcba"
"zyxdcba"
"zyxecba"
"zyxedba"
"zyxedca"
"zyxedcb"
The largest string among them, based on dictionary order, is
"zyxedcb", so that is the answer.
Sample Case 1
Sample Input For Custom Testing
2
rim
Sample Output
r
Explanation
The input string, s, is "rim", and the number of characters to erase
is k= 2.
The possible ways of erasing exactly 2 characters are :
"r"
"i"
"m"
The largest string among them, based on dictionary order, is "r", so
that is the answer.
2) Perfect Array
Your friend is not able to solve a question in the recent
HackerRank League Contest and wants you to help them out. You are
given two arrays consisting of integers, denoted as firstArray and
secondArray respectively. A Perfect Array is defined as an array
that can be converted to secondArray by removing some integers, and
the removal of integers maintains its relative order.
For example, let firstArray = [3,1,4,2,5] and secondArray =
[3,4,51. Here, firstArray is a Perfect Array because we can remove
the integers 1 and 2 from it so that firstArray is equal to
secondArray. As another example, let firstArray = [3,1,4,2,51 and
secondArray = [4,5,7]. Here, firstArray is not a Perfect Array as we
cannot make it equal to secondArray by removing integers. Because
firstArray cannot always be a Perfect Array, what Is the minimum
number of integers you need to insert anywhere into firstArray so
that it can become a Perfect Array?
For example:
firstArray = [4. 5, 1, 7, 8]
secondArray = [4, 8, 7]
Here, firstArray is not a Perfect Array because removing integers 5
and 1 makes [4, 7, 8], which is not equal to secondArray. Adding 7
at the end of firstArray makes it [4, 5, 1, 7, 8, 7).
Now, removing the second, third, and fourth integers (5, 1, and 7)
gives us [4, 8, 7], which is equal to secondArray. Hence, the
minimum number of insertions to be made in firstArray is 1.
Function Description
'Complete the function getMinInsertions in the editor below. The
function must return an integer denoting the number of integers to
be added to firstArray so that It becomes a Perfect
Array.
- getMinInsertions has the following parameters:
- firstArray: an array at integers
- secondArray: an array of integers
Constraints
• 1 <=size of firstArray <= 10^5
• 1 <=size of secondArray <= 10^5
• 1 <= firstArray[i] <= 10^9
• 1 <= secondArray[i] <= 10^9
• secondArray consists of distinct elements
Input Format For Custom Testing
The first line contains an integer, n, denoting the number of
elements in firstArray. Each line i of the n subsequent lines (where
0<= i < n) contains an integer describing firstArray[il. The
next line contains an integer, m, denoting the number of elements in
secondArray. Each line j of the m subsequent lines (where 0 <= j
< m) contains an integer describing secondArray[j].
Sample Case 0
Sample Input for Custom Testing
2
3
2
1
2
Sample Output
0
Explanation
Here , firstArray={3,2}and secondArray={2}
Removing 3 from firstArray Makes it equal to secondArray. Hence
firstArray is already Perfect
Array and as no insertions were needed the answer is 0.
Sample Case 1
Sample Input For Custom Testing
3
4
3
2
3
2
3
7
3
11
Sample Output
2
Explanation
Here, firstArray={ 4, 3, 2} and secondArray={7,3,11},
firstArray cannot directly be converted to secondArray, hence it is
not a Perfect Array. By inserting integers 7 and 11 in firstArray,
making it {7, 4, 3, 2.,11}, firstArray becomes a Perfect .This is
because removing Integers 4 and 2 makes firstArray equal to
secondArray. Hence, the number of insertions needed in firstArray is
2,
3. AND Queries
You have a large amount of data you need to store. You are interested
in knowing some details about the structure of your data in binary in
order to optimize how it is stored. In particular, you are interested
in the bitwise AND of certain contiguous subarrays of its elements to
do so, you try to answer some queries.
You're given an array A of n numbers. There are q queries that you
need to answer. Each query is of the form l r s t. For each contiguous
subarray in the range l to r (inclusive), we define p as the bitwise
AND of all its elements. The answer to each query is the number of
contiguous subarrays of size s in this range that has p >=
t.
For example, given n = 6 numbers {21, 29, 31, 15, 13, 5} and a query
4 6 2 7, the range is [15, 13, 5]. In this, we need to find for how
many subarrays of size 2 the value of p >= 7. The subarrays of size
2 are [15, 13] and [13, 5]. These have p values of 13 and 5. Therefore
the output should be 1 since there is 1 subarray of size 2 ([15,13])
having p>= 7.
Function Description
Complete the function and Queries in the editor below.
- andQueries has the following parameter(s):
- int number[n]:an array of integers
- int queries[q][4]: a 2d array of integers where queries[i] contains the ith query.
The Function returns an array of q integers, the answer to each of
the q queries.
Constraints
- 1 <= n <= 10^5
- 1 <= q <= 500
- 1 <= l <= r <= n
- 1 <= s <= r-l+1
- 1 <= A[i] , t < 2 ^31
Input Format For Custom Testing
The first line contains a single integer, n, denoting the number of
element.
The next n lines contain the elements of A
The next line contains a single integer, q, denoting the number of
queries.
The next line always contains the integer 4 ( for input
purposes).
The next q lines contain 4 space separated integer denoting l r
s t for each II query.
Sample Case 0
Sample input For Custom Testing
5
2
5
4
8
3
1
4
2 5 2 4
Sample Output
1
Explanation
The sub-array is [5, 4, 8, 3].
Now the possible subarrays of size 2 are [5,4],[4,8] and [8,3].
These have p values 4, 0 and 0 respectively. So the number of
subarrays of size 2 from l to r where p>= 4 is 1.
Sample Case 1
Sample Input For Custom Testing
10
53
21
23
19
17
49
57
61
57
3
4
2 5 1 9
7 10 3 45
4 10 4 28
Sample Output
4
2
2
Explanation In the first query, all 4 elements of the range
are greater than 9. In the second query , there are two sub-arrays,
both having p values of 57. In the 3rd query, the p values are
17,17,49 and 57.
Comments
Post a Comment
We need people who give us feedback and this is how we grow. Please do comment if you find something faulty, wrong , helpful, valuable in anyway. You can comment anonymously. Thanks for your contribution.