The process at ServiceNow consisted of 4 rounds: 1 Online Test, 2 Technical Rounds, 1 Technical Round + Manager Round.
Round 1: Online Test on HackerRank (2 DSA+1 SQL)
Platform: HackerRank
Time Limit: 105 minutes
DSA Questions:
1.Maximum sum of mountain elements of size 3, given an array of integers in any order, return the maximum of a+b+c where a, b, c are subsequences in the array,
and a < b > c.
Difficulty : Easy leetcode question
2.Numbers of Possible Arrays in Each Query
Given an array of integers, its totalCost is calculated as follows , where n = the number of elements in the array and the array itself is named element.
currentMaximumElement = element[0]
totalCost = 0
for ( i = 1; i < n; i += 1){
if (element[i]>currentMaximumElement){
currentMaximumElement=element[i]
totalCost+=1
}
}Given three values, n, m, and totalCost, find the number of distinct arrays that meet the following criteria .
Each array consists of n integers.
1<= value at index i in each array <= m, where 0<=i< n.
The cost to find the maximum element of each array is equal to totalCost.
Two arrays are said to be distinct if there exists at least one index i (where 0<=i<n) such that the elements at index i are not equal.
For example, given values n=4, m=4, and totalCost=2. With totalCost=2 increases in maximum value from the initial value at element 0 and n=4 elements, each element is between 1 and m=4 inclusive. There are 30 such arrays:
[1,1,2,3], [1,2,1,3], [1,2,3,1],[1,2,2,3], [1,2,3,2],[1,2,3,3],[1,1,2,4], [1,2,1,4], [1,2,4,1],[1,2,2,4], [1,2,4,2],[1,2,4,4],[1,1,3,4], [1,3,1,4], [1,3,4,1],[1,3,3,4], [1,3,4,3],[1,3,4,4],[2,2,3,4], [2,3,4], [2,3,4,2],[2,3,3,4], [2,3,4,3],[2,3,4,4],[2,1,2,3], [2,1,2,4], [2,1,3,4],[2,3,1,4],[2,3,2,4], [2,3,4,1]
Complete the Function
vector<int> arraysCount(vector<int> n,vector<int> m, vector<int> totalCost){
}Function Description
**
The function must return an array of integers where each answer[i] equals the number of arrays that meet the criteria for the query, modulo 10^9 +7.
Sample Input/Output:
The arrays are n=[2, 3, 4], m= [3, 3, 3], and totalCost=[1, 2, 2]. Let the return array be answers, then:
answers[0] describes the value arraysCount(n[0] =2, m[0]=3, totalCost[0] = 1) i.e., the total number distinct of arrays such that
Each array consists of 2 elements
1 <= value at each index i in each array ≤ 3, where 0<=i<2
The cost of finding the maximum element of each array = 1
The following three arrays meet the criteria:
[1,2]
[1,3]
[2,3]
Answer for this query is 3.
Similarly the answers array has to be [3,1,6].
Constraints:
1<q<=50
1<=n[i]<=50, where 0<=i<q
1<=m[i]<=100, where 0<=i<q
0<=totalCost[i]<n[i]. Where 0<=i<q
Difficulty :(Medium LeetCode DP question)
This question needs a good understanding of recursion and is easier if you've practiced at least 10 different varieties of DP problems.
3. SQL Question
A vaccine is administered in two doses.it is best if the doses are given between 48 and 72 days apart inclusive
Write my sql query to return the percentage of beneficiaries who received both doses within recommended time period, rounded to nearest integer
Table doses
Dose_id,BBeneficiairy_id, dose_type, vaccination date
Those who solve all the 3 got mail for the interviews.
Round 2: Technical Interview 1
Description: This round exclusively focused on DSA and resume.
First 15 mins we discussed about projects mentioned in my resume, she asked basic questions like,
Problem Statement,Definitions of the libraries and techstacks used, applications in real life,etc
DSA Question: Leetcode 572. Subtree of Another Tree asked for different approaches along with time and space complexities, from brute to optimal.
Round 3: Technical Interview 2
Description: This round primarily focused on easy data structures and algorithms (DSA) ,OOPs and Puzzles.
DSA Questions:
1.Print Spiral Order for the matrix.
2.Didn't remember the exact question but can be solvable using bfs for tree with slight modification.
3.a+b+c =k / 3Sum from leetcode (asked for optimal approach).
OOPS:
1. Characteristics of oops.
2. Differences between Abstract class and interface.
Puzzles: Towards the end, the interviewer presented two puzzles. While I managed to solve one of them, the other posed a greater challenge.
Round 4: Technical + Managerial Interview
Description: This round combined brief description of projects mentioned and past experiences with managerial evaluation.
Technical Discussion: I was asked the reason behind choosing each project and selecting required libraries and frameworks.
Managerial Discussion: Questions on how to take inputs from the manager, where do I want to see myself in next 5 years,my interests in tech and hobbies.
**