# ServiceNow Interview Experience | Set 6 (On-campus)

• Last Updated : 07 Dec, 2018

Online round
Solve 30 questions in 30 minutes. Multiple choice questions. Questions were based on exceptions, inheritance, recursion, bitwise operators, sorting, searching, time complexities, C and Java input/output questions, OS and around 5 aptitude questions.
Most of the questions were basic and can be solved in one minute. If you don’t waste time on lengthy problems, it is easy to score around 25.

Technical round 1
– Questions based on resume and projects.
– Sudoku problem approach (Backtracking). Partially solved.
– Print maximum of k-set of numbers in an array of size n.
E.g.: Input:
n=8
10 7 8 5 11 12 3 2
k=3
Output: 10 8 11 12 12 12
I told the brute force approach with time complexity O((n-k)*k).
Then I optimized it using max heap of size k which reduced time complexity to O((n-k)*logk).
– Which is the best algorithm for sorting given array : 0 1 2 2 2 1 0 0 1 2
Since all the values are in the range 0-2 use counting sort. I wrote the code and explained time and space complexity.
– Questions based on user interface: HTML, CSS.
– B-trees and its applications.
– When we enter a URL, how is the website opened? Explain DNS lookup.
– Mirror image of a given tree without creating a new tree. Wrote the code using recursion.
– What is a primary key, composite key, foreign key?

Technical round 2
– Explain the database schema for any favorite project.
– Given an array with distinct elements increasing and then decreasing, search for an element and output its index.
E.g.: Input: 2 5 7 11 10 9 8 4 3 1 search for 9.
Output: 5
Used binary search for finding the peak element. Apply binary search on two subarrays (0, peak_index) and (peak_index+1, last_index). As we don’t know which subarray has the element, binary search on both sorted parts separated by peak element. I wrote the code and explained time complexity.
– How is FIFO implemented in OS? I explained about different states of process and queue to implement FIFO.
– What is thrashing?
– If n dice are thrown, print all possible outcomes. I used recursion and wrote the code.

Technical round 3
– Pick your favorite project and draw the ER diagram with associations for that.
– Explain all tables and relations between them. (Primary and foreign keys)
– Given a change in some feature, how would you reflect it in the database? (In chosen project)
– I was asked to write an SQL query based on those tables to find top 5 with the max count.
– Rotate an array (of size n) k times left.
I specified two approaches
Then I was asked to write code for the second approach. After checking my code, he asked what would happen if k>n. I added k%=n.
– If a group of people have some transactions, how many minimum further transactions are required to settle all of them. I used a graph to represent this situation. I wrote code to calculate the profit of each person at the end of all transactions (if loss, negative). Then I told a strategy to settle all of them. He said that I was close to the answer.
– Then I was asked to rate my performance in the interview.

HR round