ServiceNow | Online Assessment | 40 min | Bangalore | 7+YOE
Anonymous User
2246

I forgot to take the screenshot of the question, otherwise, it would have been easy for me to just upload the screenshot. :D

Anyway, question was clear to me, so sharing it here. It may not be exact word. So, please post if you need any more clarity on the problem statement.

This assessment had only one question from Graph and time limit was 40 mins. I was able to clear 7/8 test cases though.

Question :

You are given total number of nodes and NodeFrom and NodeFrom, which indicates their relation. We need to calculate the square root on total count of connected node and apply ceiling. Then sum them all.

input (Sample input):

Total number of nodes : 10
NodeFrom : [1,1,2,3,6]
NodeTo : [2,3,4,5,7]

Referring above input, this implies below :
image

Output :

5 = Math.ceil(Math.sqrt(5)) = 3
2 = Math.ceil(Math.sqrt(2)) = 2
1 = Math.ceil(Math.sqrt(1)) = 1

So final result is : 3 + 2 + (3x1) = 8

Comments (6)