### codenationtest's blog

By codenationtest, history, 3 months ago, ,

Q1 : Represent N as sum of minimum numbers ending with 9. eg 28 = 19 + 9, 27 = 9 + 9 + 9.

Q2: Make frequency of each digit even and minimize the last — first deleted numbers index difference.

Q3: Maximum diameter of tree where parent of x = (x — x&(x-1) ). ie last bit unset.

Q4: array of site n, multiply or divide(if possible) by k any number of times. return minimum (MAX — Min) element of modified array.

Q5: online queries of type 1) change value of index x to v. 2) sum of all values with index <= x Q <= 1e5 x <= 1e18

Q6: return max product of size of 2 non intersecting palindromic substring. required in O(n).

• +67

By codenationtest, history, 5 months ago, ,

Codenation test was conducted on Hackerrank on 15th July. There were 3 questions in the hiring contest.

Q1) Given a NxM (NxM <= 1e5) matrix with each cell having a value mod(Aij) <= 1e9. Job is to rank each element by the following rules:

1) Ranks start from 1.
2) Equal elements in the same row or same column should have the same rank.
3) Greater elements in the same row or same column should have a greater rank.
4) Maximum Rank should be minimized.

Print the final rank matrix.

Q2) N employees are given, you have to divide them into teams of two. If n is odd the last person will form a one man team. Problem is all employees are not compatible with each other. and if both are compatible with each other then only a team can be formed.

Aij ='C' if employee i is compatible with employee j, Aij = 'X' otherwise.
Aii ='C' if employee i can work as one man team, Aii = 'X' otherwise.

find the maximum no of valid teams that can be formed. constraints: T <=20, N<=18.

Q3) Given a Directed graph with N nodes and M edges. each node has a population Ai. you have to open outlets in some or all nodes following the conditions in decreasing priority:

1) Every Node must have access to some outlet either directly or through some path.
2) Maximize the average sales per outlet. sales are linearly proportional to the no of people that visit that
location. Average sales per outlet = (sum of all outlet sales)/(total number of outlets)
3) Minimize the number of outlets.

Print how many outlets will you open and in which node. Constraints : T <= 100, N <= 1e3, M <= min( 1e5, N(N-1)), Ai <= 1e3.