Codenation Interview Experience | Online Test
Recently, on-campus drive was held for Codenation for Software Development Engineer Intern.
The process was:
1. Online Test
2. Telephonic Interview
3. Skype Interview
Online test for on-campus was held on September 15th 2020. The off-campus coding challenge known as CodeAgon for the hiring of same position is going to be held on 28th of September. So, I just wanted to share questions asked in online test.
There were three questions:
Alice has got a Random Number Generator. The generator generates a random number from 1 to N.
Now Alice wants to know the expected number of turns until K distinct elements are generated.
Help Alice find this value modulo 109+7.
Input consists of 2 arguments, N=A and K=B in this order.
Return a single integer , the expected value modulo 109+7.
Given a grid A of size N*M, 2 players are playing a game on it taking alternate turns.
In each turn, a player chooses a subset of elements from any row and replaces each one of them with their proper divisor.
A proper divisor of a number N is any divisor of N, not equal to N.
The player who is unable to move, loses. Determine the winner of the game.
- 1<=N, M<=103
The only line of argument contains the grid A.
Return a single integer, 1 or 2 , depending upon which player wins.
Given a tree of N nodes numbers 0 to N-1. Each node have binary value i.e 0 or 1 denoted by integer array A.
The beauty of a ith node is 2i*A[i]. The total beauty of the Tree is sum of beauty of each node.
Aman is superstitious and will accept the tree only its total beauty is 2N -1 or 0.
He asked you to make the tree acceptable but you can only use the following operation.
- In each operation, select any node X and call flip(X).
Find the minimum number of operation required to make the tree acceptable.
- 0<=A[i] <=1
- 0<=B[i], B[i]<=N-1
First argument is an integer array A of size N denoting the node value.
Second argument is a 2D array B of size (N-1)*2 where ith edge is between B[i] and B[i] node
Return an integer denoting the minimum number of operations required.