CIS - Cyber Infrastructure interview experience Real time questions & tips from candidates to crack your interview

SDE - 1

CIS - Cyber Infrastructure
upvote
share-icon
3 rounds | 10 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 4 months
Topics: Data Structures, Algorithms, DBMS, OS, Aptitude, OOPS
Tip
Tip

Tip 1 : Must do Previously asked Interview as well as Online Test Questions.
Tip 2 : Go through all the previous interview experiences from Codestudio and Leetcode.
Tip 3 : Do at-least 2 good projects and you must know every bit of them.

Application process
Where: Campus
Eligibility: Above 7 CGPA
Resume Tip
Resume tip

Tip 1 : Have at-least 2 good projects explained in short with all important points covered.
Tip 2 : Every skill must be mentioned.
Tip 3 : Focus on skills, projects and experiences more.

Interview rounds

01
Round
Medium
Online Coding Test
Duration75 minutes
Interview date17 Jul 2020
Coding problem2

The round had 2 coding problems to solve with varying difficulty. Each candidate had a different set of questions. The round was around 2 pm. The webcam was turned on to keep an eye on candidates.

1. Merge two sorted lists (in-place)

Moderate
15m average time
80% success
0/80
Asked in companies
HSBCAmazonApple

You are given two sorted linked lists. You have to merge them to produce a combined sorted linked list. You need to return the head of the final linked list.

Note:

The given linked lists may or may not be null.

For example:

If the first list is: 1 -> 4 -> 5 -> NULL and the second list is: 2 -> 3 -> 5 -> NULL

The final list would be: 1 -> 2 -> 3 -> 4 -> 5 -> 5 -> NULL
Problem approach

Approach 1 (Recursive) :

1) Compare the head of both linked lists.


2) Find the smaller node among the two head nodes. The current element will be the smaller node among two head nodes.
 

3) The rest elements of both lists will appear after that.
 

4) Now run a recursive function with parameters, the next node of the smaller element, and the other head.
 

5) The recursive function will return the next smaller element linked with rest of the sorted element. Now point the next of current element to that, i.e curr_ele->next=recursivefunction()


6) Handle some corner cases.
6.1) If both the heads are NULL return null.
6.2) If one head is null return the other.

TC : O(N), where N=length of the Linked List
SC : O(N)


Approach 2 (Iterative) :

1) Traverse the list from start to end.
 

2) If the head node of second list lies in between two nodes of the first list, insert it there and make the next node of second list the head. Continue this until there is no node left in both lists, i.e. both the lists are traversed.


3) If the first list has reached end while traversing, point the next node to the head of second list.

Note: Compare both the lists where the list with a smaller head value is the first list.


TC : O(N), where N=length of the Linked List
SC : O(1)

Try solving now

2. Make Array Elements Equal

Moderate
25m average time
75% success
0/80
Asked in companies
CIS - Cyber InfrastructureMakeMyTrip

You are given an array of integers of size ‘N’. You have to make the elements of the array equal, and the cost of changing the element ‘x’ to ‘y’ is abs(x -y). Your task is to find the minimum cost to make the elements of the array equal.

For example:
Consider ARR = [3, 4, 5] now suppose if we want to change every element value to 4, then the cost of changing 3 to 4 is |3 - 4| which is 1, and the cost of changing 5 to 4 is |5 - 4| which is 1, so the total cost is 1 + 1 = 2. The value 2 is the minimum cost to make all values in the array equal. Hence, the answer is 2.
Problem approach

Approach :

1) We will initialize the variable lowerLimit and upperLimit with the minimum and maximum value present in the array.

2) Iterate while upperLimit - lowerLimit is more than 2.
2.1) Set the variables mid1 with lowerLimit + (upperLimit - lowerLimit)/3 and mid2 with upperLimit - (upperLimit - lowerLimit)/3.

2.2) Initialize the variable cost1 with the cost of converting all array elements to mid1. You have to iterate the complete array to calculate cost1.

2.3) Similarly, find cost2 by keeping mid2 as the target value of all elements in the array.

2.4) If cost1 is less than cost2 then set upperLimit as mid2; otherwise, set lowerLimit as mid1.

3) Set target as (lowerLimit + upperLimit)/2 and cost as 0. The variable cost stores the minimum cost to convert all elements present in the array to target.

4) Iterate index from 0 to N-1.
4.1) Increment cost by an absolute difference of ARR[index] and target.

5) Return the variable cost.


TC : O(N * log(Max(ARR) - Min(ARR))) where N = size of the array.
SC : O(1)

Try solving now
02
Round
Medium
Video Call
Duration50 minutes
Interview date17 Jul 2020
Coding problem2

This round had 2 questions related to DSA. I was first asked to explain my approach with proper complexity analysis and then code the soution in any IDE that I prefer.

1. Count Subarrays with XOR=X

Moderate
15m average time
85% success
0/80
Asked in companies
ArcesiumUberCIS - Cyber Infrastructure

Given an array of integers ‘ARR’ and an integer ‘X’, you are supposed to find the number of subarrays of 'ARR' which have bitwise XOR of the elements equal to 'X'.

Note:
An array ‘B’ is a subarray of an array ‘A’ if ‘B’ that can be obtained by deletion of, several elements(possibly none) from the start of ‘A’ and several elements(possibly none) from the end of ‘A’. 
Problem approach

Approach 1 (Brute Force) :

1) Create a variable ans, which stores the total number of subarrays. We will set the variable ans as 0.


2) Iterate index from 0 to N - 1.
 

3) Iterate pos from index to M - 1.
3.1) We will maintain a variable currentXor, which will store the XOR of all elements present in the current subarray. We will set currentXor as 0.
 

4) We will traverse num from index to pos. We will update currentXor with XOR of currentXor and ARR[num].
4.1) Check if currentXor is equal to X.
4.2) Increment ans by 1.


5) Return the variable ans.

TC : O(N^3), where N=size of the array
SC : O(1)


Approach 2 (Using Hashing) :

1) Create a HashMap “prefXor” which stores the count of subarrays having a particular XOR value.
 

2) Create a variable “curXor” which stores the XOR for ‘i’ elements. Initialise it with zero. Also, create a variable called “ans” to store the count of the subarrays having XOR ‘X’.
 

3) Start iterating through given array/list using a variable ‘i’ such that 0 <= ‘i’ < n
3.1) Update the “curXor” i.e. curXor = curXor ^ arr[i]
3.2) Store the required value of the prefix Xor to make the XOR of the subarray ending at the current index equal to X i.e. req = X ^ curXor
3.3) Now add the count of prefix arrays with required xor i.e. ans = ans + prefXor[req]
3.4) Update the “prefXor” HashMap with the “curXor” i.e. prefXor[curXor] = prefXor[curXor] + 1


TC : O(N), where N=size of the array
SC : O(N)

Try solving now

2. Merge K sorted arrays

Moderate
15m average time
85% success
0/80
Asked in companies
MathworksMicrosoftOracle

You have been given ‘K’ different arrays/lists, which are sorted individually (in ascending order). You need to merge all the given arrays/list such that the output array/list should be sorted in ascending order.

Problem approach

Approach 1 (Brute Force) :

Create an output array and and one by one copy all arrays to it. Finally, sort the output array using. This approach takes O(N Logn N) time where N is count of all elements.
 


Approach 2 (Using Min-Heap) :

1. Create an output array.


2. Create a min heap of size k and insert 1st element in all the arrays into the heap
 

3. Repeat following steps while priority queue is not empty.
3.1) Remove minimum element from heap (minimum is always at root) and store it in output array.
3.2) Insert next element from the array from which the element is extracted. If the array doesn’t have any more elements, then do nothing.

TC : O(N*log(K))
SC : O(N)

Try solving now
03
Round
Medium
Video Call
Duration60 minutes
Interview date17 Jul 2020
Coding problem6

This round had 2 Algorithmic questions wherein I was supposed to code both the problems after discussing their approaches and respective time and space complexities . After that , I was grilled on some OOPS concepts related to C++.

1. Longest Palindromic Substring

Moderate
20m average time
80% success
0/80
Asked in companies
MathworksLivekeeping (An IndiaMART Company)Goldman Sachs

You are given a string 'str' of length 'N'.


Your task is to return the longest palindromic substring. If there are multiple strings, return any.


A substring is a contiguous segment of a string.


For example :
str = "ababc"

The longest palindromic substring of "ababc" is "aba", since "aba" is a palindrome and it is the longest substring of length 3 which is a palindrome. 

There is another palindromic substring of length 3 is "bab". Since starting index of "aba" is less than "bab", so "aba" is the answer.
Problem approach

Approach :

1) Create a 2-D dp boolean vector(with all false initially) where dp[i][j] states whether s[i...j] is a palindrome or not and initilialise a variable ans=1 which will store the final answer.

2) Base Case : For every i from 0 to n-1 fill dp[i][i]=1 ( as a single character is always a palindrome ).

3) Now, run 2 loops first one from i=n-1 to i=0 (i.e., tarverse from the back of the string) and the second one from j=i+1 to n.

4) For every s[i]==s[j] , check if(j-i==1 i.e., if s[i] and s[ j] are two consecutive same letters) or if(dp[i+1][j-1]==1 or not i.e., if the string s[i+1,....j-1] is palindrome or not.

5) Because if the string s[i+1,....j-1] is a palindrome and s[i]==s[j] then s[i] and s[j] can be appended at the starting and the ending position of s[i+1,...j-1] and s[i...j] will then be a palindrome , so mark dp[i][j]=1 and update the answer as ans=max(ans , j-i+1).

6) Finally return the ans.

TC : O(N^2) where N=length of the string s
SC : O(N^2)

Try solving now

2. Explain Quick Sort Algorithm

Moderate
10m average time
90% success
0/80
Asked in companies
Samsung R&D InstituteLenskart.comSamsung

You are given an array of integers. You need to sort the array in ascending order using quick sort.

Quick sort is a divide and conquer algorithm in which we choose a pivot point and partition the array into two parts i.e, left and right. The left part contains the numbers smaller than the pivot element and the right part contains the numbers larger than the pivot element. Then we recursively sort the left and right parts of the array.

Example:

Let the array = [ 4, 2, 1, 5, 3 ]
Let pivot to be the rightmost number.

example

After the 1st level partitioning the array will be { 2, 1, 3, 4, 5 } as 3 was the pivot. After 2nd level partitioning the array will be { 1, 2, 3, 4, 5 } as 1 was the pivot for the left part and 5 was the pivot for the right part. Now our array is sorted and there is no need to divide it again.

Problem approach

Approach :

1) Select any splitting value, say L. The splitting value is also known as Pivot.
 

2) Divide the stack of papers into two. A-L and M-Z. It is not necessary that the piles should be equal.

 

3) Repeat the above two steps with the A-L pile, splitting it into its significant two halves. And M-Z pile, split into its halves. The process is repeated until the piles are small enough to be sorted easily.

 

4) Ultimately, the smaller piles can be placed one on top of the other to produce a fully sorted and ordered set of papers.
 

5) The approach used here is reduction at each split to get to the single-element array.
 

6) At every split, the pile was divided and then the same approach was used for the smaller piles by using the method of recursion.

 

Technically, quick sort follows the below steps:

 

Step 1 − Make any element as pivot

Step 2 − Partition the array on the basis of pivot

Step 3 − Apply quick sort on left partition recursively

Step 4 − Apply quick sort on right partition recursively

 

 

//Pseudo Code :

 

quickSort(arr[], low, high)
{
	if (low < high)
	{
		pivot_index = partition(arr, low, high);
		quickSort(arr, low, pivot_index - 1); // Before pivot_index
		quickSort(arr, pivot_index + 1, high); // After pivot_index
	}
}

partition (arr[], low, high)
{
	// pivot - Element at right most position
	pivot = arr[high];
	i = (low - 1);
	for (j = low; j <= high-1; j++)
	{
		if (arr[j] < pivot)
		{
			i++;
			swap(arr[i], arr[j]);
		}
	}
	swap(arr[i + 1], arr[high]);
	return (i + 1);
}

 

Complexity Analysis :

TC : Best Case - O(N*log(N))

Worst Case - O(N^2)

 

SC : Average Case - O(log(N))

Worst Case - O(N)

Try solving now

3. OOPS Question

What is Early Binding and Late Binding in C++ ?

Problem approach

OOP is used commonly for software development. One major pillar of OOP is polymorphism. Early Binding and Late Binding are related to that. Early Binding occurs at compile time while Late Binding occurs at runtime. In method overloading, the bonding happens using the early binding. In method overriding, the bonding happens using the late binding. The difference between Early and Late Binding is that Early Binding uses the class information to resolve method calling while Late Binding uses the object to resolve method calling.


Early Binding : In Early Binding, the class information is used to resolve method calling. Early Binding occurs at compile time. It is also known as the static binding. In this process, the binding occurs before the program actually runs. Overloading methods are bonded using early binding.


Late Binding : In Late Binding, the object is used to resolve method calling. Late Binding occurs at runtime. It is also known as dynamic binding. In this process, the binding occurs at program execution. Overridden methods are bonded using late binding.

4. OOPS Question

What is Data Abstraction and how to achive it ?

Problem approach

1) Data abstraction is a very important feature of OOPs that allows displaying only the important information and hiding the implementation details.

2) For example, while riding a bike, you know that if you raise the accelerator, the speed will increase, but you don’t know how it actually happens.

3) This is data abstraction as the implementation details are hidden from the rider.

Data abstraction can be achieved through : 
i) Abstract class
ii) Abstract method

5. OOPS Question

What is Diamond Problem in C++ and how do we fix it?

Problem approach

The Diamond Problem : The Diamond Problem occurs when a child class inherits from two parent classes who both share a common grandparent class i.e., when two superclasses of a class have a common base class.

Solving the Diamond Problem in C++ : The solution to the diamond problem is to use the virtual keyword. We make the two parent classes (who inherit from the same grandparent class) into virtual classes in order to avoid two copies of the grandparent class in the child class.

6. OOPS Question

What are Friend Functions in C++?

Problem approach

1) Friend functions of the class are granted permission to access private and protected members of the class in C++. They are defined globally outside the class scope. Friend functions are not member functions of the class.

2) A friend function is a function that is declared outside a class but is capable of accessing the private and protected members of the class.

3) There could be situations in programming wherein we want two classes to share their members. These members may be data members, class functions or function templates. In such cases, we make the desired function, a friend to both these classes which will allow accessing private and protected data members of the class.

4) Generally, non-member functions cannot access the private members of a particular class. Once declared as a friend function, the function is able to access the private and the protected members of these classes.

Some Characteristics of Friend Function in C++ :

1) The function is not in the ‘scope’ of the class to which it has been declared a friend.
2) Friend functionality is not restricted to only one class
3) Friend functions can be a member of a class or a function that is declared outside the scope of class.
4) It cannot be invoked using the object as it is not in the scope of that class.
5) We can invoke it like any normal function of the class.

Here's your problem of the day

Solving this problem will increase your chance to get selected in this company

Skill covered: Programming

How do you remove whitespace from the start of a string?

Choose another skill to practice
Similar interview experiences
company logo
SDE - 1
3 rounds | 5 problems
Interviewed by CIS - Cyber Infrastructure
2198 views
0 comments
0 upvotes
company logo
SDE - 1
3 rounds | 4 problems
Interviewed by CIS - Cyber Infrastructure
785 views
0 comments
0 upvotes
company logo
SDE - 1
3 rounds | 3 problems
Interviewed by CIS - Cyber Infrastructure
498 views
0 comments
0 upvotes
company logo
SDE - 1
3 rounds | 3 problems
Interviewed by CIS - Cyber Infrastructure
581 views
1 comments
0 upvotes
Companies with similar interview experiences
company logo
SDE - 1
2 rounds | 3 problems
Interviewed by BNY Mellon
6365 views
3 comments
0 upvotes
company logo
SDE - 1
3 rounds | 6 problems
Interviewed by BNY Mellon
0 views
0 comments
0 upvotes
company logo
SDE - 1
3 rounds | 7 problems
Interviewed by BNY Mellon
0 views
0 comments
0 upvotes