## Recent Interview Questions

More Questions »- 0of 0 votes

AnswersWe are given a undirected tree with N (1 to N) nodes rooted at node 1. Every node has a value assigned with it, represented by array - A[i] where i:[1:N].

- khatribalak December 03, 2021 in United States

We need to answer Q queries of type : -> V X : longest length of the common prefix between V and any ancestor of X including X, in their binary representation of 62-bit length.

Common prefix between 2 numbers is defined as:

Example :

4: 0..................0100 (62-bit binary representation)

6: 0..................0110

Considering both as 62-bit in it's binary representation.

Longest length of the common prefix is: 60 (as 60 left most bits are same.)

Now we are given the N (num nodes), edges, nodes values (A[i]) and queries, and we need to answer each query in optimal time.

Constrains :

N <= 10^5, number of nodes

A[i] <= 10^9, value of each node

Q <= 10^5 ,number of queries

Edge[i] = (i, j) <= N

Approach :

Create tree and track the immediate parent of each node.

for Each Query : [V, X], traverse each node n(in the path from X to root) and XOR each node's values with V and find the most significant set bit for each of the XOR operation and pick the minimum one among all of them.

So the result for Query : [V, X] : 62 - (1 + Step-2 result).

Is there any other efficient way to solve this problem? As the above approach in worst case takes O(n^2) time.| Report Duplicate | Flag | PURGE

Hi5 SDE1 - 0of 0 votes

AnswersWe are given a graph of N nodes. (1-N), where each node has exactly 1 directed edge to some node (this node can be the same node).

We need to answer the queries of type : A, B, which asks time required when 2 objects collide if one start at A and other start at B. Both moves 1 hop in 1 sec. If it's not possible for them to collide time would be -1.

Time : from X -> to Y : 1 hop = 1 second.

Constraints :

N, Q <= 10^5 (number of nodes, number of queries).

Example : for given graph`A -> B -> C -> D -> E ^ | K <- F`

Query(A, E) : 3 seconds, as at time t = 3 secs they both will be on node D.

- tusharrawat831 December 02, 2021 in United States

Query(C, D) : -1 seconds, as they will never collide.

Brute force will take O(Q * N) time. Can we do better than that?| Report Duplicate | Flag | PURGE

Hi5 Software Developer Programming Skills - 0of 0 votes

AnswersWhat is mean by on-the-job training and off-the-job training

- hr@zynofus.com December 02, 2021 in India| Report Duplicate | Flag | PURGE

zynofus Technologies private limited HR - 0of 0 votes

AnswersWhat is mean by onboarding process

- hr@zynofus.com December 02, 2021 in India| Report Duplicate | Flag | PURGE

zynofus Technologies private limited HR - 0of 0 votes

AnswersWhat is mean by 360 degree performance appraisal?

- hr@zynofus.com December 02, 2021 in India| Report Duplicate | Flag | PURGE

zynofus Technologies private limited HR