# ServiceNow Interview Experience NIT Rourkela (On-Campus)

The process started with an online test consisting of 10 multiple-choice-questions(15 minutes) and one programming question. There was a catch about the online round. We had to attempt the MCQs first and after 15 minute we had to go to programming section and we could not go to the MCQ section. The MCQs were based on mostly computer science stuff like paging, OOP concept etc and some quants on probability and other things. The questions were more or less on the easier side. The program that we had to write was Longest Increasing Sub-sequence (LIS).

### Round 1: Technical Round(Approx. 1 Hour):

Q1: Tell me about yourself like what you are interested in and all.

My ans: Programming in general, data structures, algorithms and machine learning.

Q2: Given an array of size n of positive integers find the majority element i.e. find the element that occurs more than n/2 time in the array.

My ans: First, I told him that I can take a map and store the frequency of each unique element in the map. Then I will iterate through the map to find the element with frequency>n/2. he told me to do it without using extra space. Second,  I told him that I will sort the array and the middle element will be my target element according to the rule of finding median. He then told me to do it in O(n) time without using extra space. Now this was a problem I had done in Interview Bit but could not come up with the logic at that moment even after trying very hard. Here are the links to the problem in Interview Bit and Geeksforgeeks. https://www.geeksforgeeks.org/majority-element/

Q3: You are given two arrays of integers. Suppose there is an element x in the first array with frequency y and in the second array with frequency z. Yo have to construct a new array where the frequency of x will be min(y, z) for each element x in the two arrays. You have to do it in optimal time and without using any extra space.

My ans: Sort the two arrays. Then proceed with the algorithm of merging of two sorted arrays. he was impressed with the solution.

Q4: You are given a binary tree. Given any node of that tree print all the nodes which are at d distance from the given node.

My ans: First I will find the level of the given node and suppose it is l. Now, if the given distance is d then the nodes that I have to print will be at level l+d or l-d. We can find the nodes at l+d by simply traversing the children of the given node. But while doing l-d we can sometimes encounter a negative val. If the value of l-d is negative, we have to traverse from root in the opposite subtree of that in which the given node resides and then print the elements at level -(l-d).

N.B. he asked me to implement the functions for all the above problems. i wrote the program for the first two approaches for the of the first problem, the only approach for the second one but I could not complete the code for the third one as I was stuck somewhere. He said it was okay and told me wait outside.

### Round 2: Technical Round(Approx. 90 minutes):

Q1: You are given two batches (arrays) of strings. You have to find the intersection of them in optimal way.

My ans: I took a map and count the occurrence of each string in array1. Then I traversed the second array and if that string is found in the map, I print it and mark the occurrence of that string in the array as 0. he was impressed with the solution.

Q2: There are two river-banks and water is flowing between them. There are n stones in the river and the distance between the left bank and the first stone is d1, between the 1st and 2nd stone is d2 and so on. Finally the distance between the last stone and the right bank is d(n+1). Each stone has a probability of holding your weight and they are given as p1, p2, …, pn. What is the maximum probability we can get to reach from left bank to the right bank?

My ans: I gave him a dynamic programming solution. He told that it was right but I had done a small mistake that he pointed out.

Q3: There is an array of strings. Suppose there is a string whose last character matches with the first character of another string. In that case those two form a ring. You have the find the maximum length of the ring formed by the strings in the array. Let me explain the problem with an example. Suppose the array of strings is {ear, track, tired, rat, doe}. Here the maximum ring will be ear->rat->tired->doe>ear. So, the length will be 4.

My ans: I approached the problem with a dynamic programming solution. He asked me the time complexity of my solution. I told him it will be O(n*n). He told me that it can be done in O(n). So gave it a thought but in vain.

N.B. He told to write the functions for all the above problems. I wrote codes for all the above problems except the O(n) time algorithm for the last one.

### Round 3: Managerial(Approx. 30 minutes):

The interviewer asked me about my interests and I told him the same that I told the first interviewer. He the asked me what is gradient and how it is used in machine learning. He then asked me about my B.Tech. 4th year project and gave to find a solution of  real life scenario that was related to the project. Then he asked me if I was interested in robotics and asked me a few questions on what I have done in robotics. Then he asked me to design an OR gate with NAND gate to test my knowledge about the universal gates. The last question was how can I make a child of class 8 understand what interface is. And that was all.

This was my whole interview process and I really am thankful to Geeksforgeeks for helping me so much in the preparation for placement.

Cheers and and all the best to all you guys and girls out there who are trying to get a job. Good luck.

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Previous
Next