Skip to content
Related Articles

Related Articles

Codenation Interview Experience | Online Test
  • Last Updated : 28 Sep, 2020

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:

First Question:

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

Problem Constraints:

1<=K<=N<=105



Input format:

Input consists of 2 arguments, N=A and K=B in this order.

Output format:

Return a single integer , the expected value modulo 109+7.

Second Question:

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.

Problem Constraints:

  • 1<=N, M<=103
  • 1<=A[i][j]<=106

Input format:

The only line of argument contains the grid A.

Output format:

Return a single integer, 1 or 2 , depending upon which player wins.

Third Question:

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).

Python




flip(X):
  for (v: 0 to N-1):
    if(all nodes in path from X to node v have same value)
        A[v] = 1 - A[v]


Find the minimum number of operation required to make the tree acceptable.

Problem Constraints:

  • 1<=N<=105
  • 0<=A[i] <=1
  • 0<=B[i][0], B[i][1]<=N-1

Input format:

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][0] and B[i][1] node

Output format:

Return an integer denoting the minimum number of operations required.


Write your Interview Experience or mail it to contribute@geeksforgeeks.org

My Personal Notes arrow_drop_up
Recommended Articles
Page :